Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Fix UrlRemap not always setting no-cache headers.
  • Loading branch information
agrieve committed Mar 21, 2014
1 parent afdd006 commit 0c9986adf833bdbffeaaac7baffa954430e4d964
Showing 1 changed file with 2 additions and 3 deletions.
@@ -258,7 +258,7 @@ + (NSURLRequest*)canonicalRequestForRequest:(NSURLRequest*)request {

- (void)issueNotFoundResponse {
NSURL* url = [[self request] URL];
NSURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:url statusCode:404 HTTPVersion:@"HTTP/1.1" headerFields:@{}];
NSURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:url statusCode:404 HTTPVersion:@"HTTP/1.1" headerFields:@{@"Cache-Control": @"no-cache"}];
[[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
[[self client] URLProtocolDidFinishLoading:self];
}
@@ -268,8 +268,7 @@ - (void)issueRedirectResponseToURL:(NSURL*)dest {
[req setURL:dest];
[req setValue:@"1" forHTTPHeaderField:@"url-remap-ignore"];

// Responses get cached regardless of if we specify Cache-Control here.
NSURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:[[self request] URL] statusCode:302 HTTPVersion:@"HTTP/1.1" headerFields:@{ @"Location": [dest absoluteString] }];
NSURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:[[self request] URL] statusCode:302 HTTPVersion:@"HTTP/1.1" headerFields:@{ @"Location": [dest absoluteString], @"Cache-Control": @"no-cache" }];

[[self client] URLProtocol:self wasRedirectedToRequest:req redirectResponse:response];
}

0 comments on commit 0c9986a

Please sign in to comment.