Revision: 29505
http://sourceforge.net/p/bibdesk/svn/29505
Author: hofman
Date: 2025-08-31 08:14:44 +0000 (Sun, 31 Aug 2025)
Log Message:
-----------
Only disallow cache for download page
Modified Paths:
--------------
trunk/bibdesk/BDSKBibDeskProtocol.m
Modified: trunk/bibdesk/BDSKBibDeskProtocol.m
===================================================================
--- trunk/bibdesk/BDSKBibDeskProtocol.m 2025-08-30 22:56:25 UTC (rev 29504)
+++ trunk/bibdesk/BDSKBibDeskProtocol.m 2025-08-31 08:14:44 UTC (rev 29505)
@@ -78,10 +78,10 @@
/*
Immediately provide the requested data.
*/
-- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType {
+- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType
cached:(BOOL)cached {
id<NSURLProtocolClient> client = [self client];
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:[[self
request] URL] MIMEType:MIMEType expectedContentLength:[data length]
textEncodingName:[MIMEType isEqualToString:@"text/html"] ? @"utf-8" : nil];
- [client URLProtocol:self didReceiveResponse:response
cacheStoragePolicy:NSURLCacheStorageNotAllowed];
+ [client URLProtocol:self didReceiveResponse:response
cacheStoragePolicy:cached ? NSURLCacheStorageAllowed :
NSURLCacheStorageNotAllowed];
[client URLProtocol:self didLoadData:data];
[client URLProtocolDidFinishLoading:self];
}
@@ -96,7 +96,7 @@
static NSData *welcomeHTMLData = nil;
if (welcomeHTMLData == nil)
welcomeHTMLData = [[self
HTMLDataUsingTemplateFile:@"WebGroupStartPage" usingObject:[BDSKWebParser
class]] copy];
- [self loadData:welcomeHTMLData MIMEType:@"text/html"];
+ [self loadData:welcomeHTMLData MIMEType:@"text/html" cached:YES];
} else if ([DOWNLOADS_SPECIFIER isCaseInsensitiveEqual:resourceSpecifier])
{
if ([[request HTTPMethod] isCaseInsensitiveEqual:@"POST"] && [[request
HTTPBody] length]) {
NSString *action = [[NSString alloc] initWithData:[request
HTTPBody] encoding:NSUTF8StringEncoding];
@@ -118,12 +118,12 @@
[client URLProtocolDidFinishLoading:self];
} else {
NSData *data = [self
HTMLDataUsingTemplateFile:@"WebGroupDownloads" usingObject:[BDSKDownloadManager
sharedManager]];
- [self loadData:data MIMEType:@"text/html"];
+ [self loadData:data MIMEType:@"text/html" cached:NO];
}
} else if ([resourceSpecifier
hasCaseInsensitivePrefix:FILEICON_SPECIFIER]) {
NSString *extension = [[resourceSpecifier
substringFromIndex:[FILEICON_SPECIFIER length]]
stringByRemovingPercentEncoding];
NSImage *icon = [[NSWorkspace sharedWorkspace]
iconForFileType:extension];
- [self loadData:[icon TIFFRepresentation] MIMEType:@"image/tiff"];
+ [self loadData:[icon TIFFRepresentation] MIMEType:@"image/tiff"
cached:YES];
} else if ([resourceSpecifier hasCaseInsensitivePrefix:IMAGE_SPECIFIER]) {
NSString *name = [[resourceSpecifier
substringFromIndex:[IMAGE_SPECIFIER length]] stringByRemovingPercentEncoding];
NSURL *imgURL = [[NSBundle mainBundle] URLForImageResource:name];
@@ -140,7 +140,7 @@
data = [[NSImage imageNamed:name] TIFFRepresentation];
MIMEType = @"image/tiff";
}
- [self loadData:data MIMEType:MIMEType];
+ [self loadData:data MIMEType:MIMEType cached:YES];
} else if ([HELP_SPECIFIER isCaseInsensitiveEqual:[[resourceSpecifier
pathComponents] firstObject]]) {
// when there's no "//" the URL we get has percent escapes including
in particular the # character, which would we don't want
NSString *URLString = [NSString stringWithFormat:@"%@://%@",
BDSKBibDeskScheme, [resourceSpecifier stringByRemovingPercentEncoding]];
@@ -162,7 +162,7 @@
NSData *data = [NSData dataWithContentsOfFile:path];
NSString *theUTI = [[NSWorkspace sharedWorkspace] typeOfFile:path
error:NULL];
NSString *MIMEType =
CFBridgingRelease(UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)theUTI,
kUTTagClassMIMEType));
- [self loadData:data MIMEType:MIMEType];
+ [self loadData:data MIMEType:MIMEType cached:YES];
} else {
[client URLProtocol:self didFailWithError:[NSError
errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit