You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/04/23 20:57:07 UTC

[11/37] git commit: ios: Don't cache responses from CDVFile's URLProtocol

ios: Don't cache responses from CDVFile's URLProtocol


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/4ca13df5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/4ca13df5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/4ca13df5

Branch: refs/heads/master
Commit: 4ca13df50eb26f0ba8909d8f816c65938e594c6a
Parents: 32ebfca
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Mar 7 16:34:48 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Mar 7 16:34:48 2014 -0500

----------------------------------------------------------------------
 src/ios/CDVFile.m | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/4ca13df5/src/ios/CDVFile.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFile.m b/src/ios/CDVFile.m
index d36fbe6..02cc6a5 100644
--- a/src/ios/CDVFile.m
+++ b/src/ios/CDVFile.m
@@ -140,13 +140,17 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
     CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithURL:[[self request] URL]];
     NSObject<CDVFileSystem> *fs = [filePlugin filesystemForURL:url];
     [fs readFileAtURL:url start:0 end:-1 callback:^void(NSData *data, NSString *mimetype, CDVFileError error) {
+        NSMutableDictionary* responseHeaders = [[NSMutableDictionary alloc] init];
+        responseHeaders[@"Cache-Control"] = @"no-cache";
+
         if (!error) {
-            NSURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:url.url statusCode:200 HTTPVersion:@"HTTP/1.1"headerFields:@{@"Content-Type": mimetype}];
+            responseHeaders[@"Content-Type"] = mimetype;
+            NSURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:url.url statusCode:200 HTTPVersion:@"HTTP/1.1"headerFields:responseHeaders];
             [[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
             [[self client] URLProtocol:self didLoadData:data];
             [[self client] URLProtocolDidFinishLoading:self];
         } else {
-            NSURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:url.url statusCode:404 HTTPVersion:@"HTTP/1.1"headerFields:@{}];
+            NSURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:url.url statusCode:404 HTTPVersion:@"HTTP/1.1"headerFields:responseHeaders];
             [[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
             [[self client] URLProtocolDidFinishLoading:self];
         }
@@ -154,8 +158,11 @@ NSString* const kCDVFilesystemURLPrefix = @"cdvfile";
 }
 
 - (void)stopLoading
-{
-    // do any cleanup here
+{}
+
+- (NSCachedURLResponse *)connection:(NSURLConnection *)connection
+                  willCacheResponse:(NSCachedURLResponse*)cachedResponse {
+    return nil;
 }
 
 @end