Philippe Jayet
Committed by Ben Copsey

Don't use the cached response if the server didn't send an explicit expiration time

@@ -292,9 +292,9 @@ static NSString *permanentCacheFolder = @"PermanentStore"; @@ -292,9 +292,9 @@ static NSString *permanentCacheFolder = @"PermanentStore";
292 // Look for an Expires header to see if the content is out of date 292 // Look for an Expires header to see if the content is out of date
293 NSString *expires = [cachedHeaders objectForKey:@"Expires"]; 293 NSString *expires = [cachedHeaders objectForKey:@"Expires"];
294 if (expires) { 294 if (expires) {
295 - if ([[ASIHTTPRequest dateFromRFC1123String:expires] timeIntervalSinceNow] < 0) { 295 + if ([[ASIHTTPRequest dateFromRFC1123String:expires] timeIntervalSinceNow] >= 0) {
296 [[self accessLock] unlock]; 296 [[self accessLock] unlock];
297 - return NO; 297 + return YES;
298 } 298 }
299 } 299 }
300 // Look for a max-age header 300 // Look for a max-age header
@@ -309,13 +309,15 @@ static NSString *permanentCacheFolder = @"PermanentStore"; @@ -309,13 +309,15 @@ static NSString *permanentCacheFolder = @"PermanentStore";
309 309
310 NSDate *expiryDate = [[[NSDate alloc] initWithTimeInterval:maxAge sinceDate:fetchDate] autorelease]; 310 NSDate *expiryDate = [[[NSDate alloc] initWithTimeInterval:maxAge sinceDate:fetchDate] autorelease];
311 311
312 - if ([expiryDate timeIntervalSinceNow] < 0) { 312 + if ([expiryDate timeIntervalSinceNow] >= 0) {
313 [[self accessLock] unlock]; 313 [[self accessLock] unlock];
314 - return NO; 314 + return YES;
315 } 315 }
316 } 316 }
317 } 317 }
318 318
  319 + // No explicit expiration time sent by the server
  320 + return NO;
319 } 321 }
320 322
321 323