Toggle navigation
Toggle navigation
This project
Loading...
Sign in
iOS
/
asi-http-request
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Ben Copsey
2010-12-02 07:13:02 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e357f3ca7c11dbe258cd25813941d9aad5b12681
e357f3ca
1 parent
8245ca54
ASIDownloadCache: If we get a max-age, ignore any Expires header
closes gh-108
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
Classes/ASIDownloadCache.m
Classes/ASIDownloadCache.m
View file @
e357f3c
...
...
@@ -299,14 +299,6 @@ static NSString *permanentCacheFolder = @"PermanentStore";
if
([
self
shouldRespectCacheControlHeaders
])
{
// Look for an Expires header to see if the content is out of date
NSString
*
expires
=
[
cachedHeaders
objectForKey
:
@"Expires"
];
if
(
expires
)
{
if
([[
ASIHTTPRequest
dateFromRFC1123String
:
expires
]
timeIntervalSinceNow
]
>=
0
)
{
[[
self
accessLock
]
unlock
];
return
YES
;
}
}
// Look for a max-age header
NSString
*
cacheControl
=
[[
cachedHeaders
objectForKey
:
@"Cache-Control"
]
lowercaseString
];
if
(
cacheControl
)
{
...
...
@@ -315,17 +307,29 @@ static NSString *permanentCacheFolder = @"PermanentStore";
[
scanner
scanString
:
@"="
intoString
:
NULL
];
NSTimeInterval
maxAge
=
0
;
[
scanner
scanDouble
:
&
maxAge
];
NSDate
*
fetchDate
=
[
ASIHTTPRequest
dateFromRFC1123String
:[
cachedHeaders
objectForKey
:
@"X-ASIHTTPRequest-Fetch-date"
]];
NSDate
*
fetchDate
=
[
ASIHTTPRequest
dateFromRFC1123String
:[
cachedHeaders
objectForKey
:
@"X-ASIHTTPRequest-Fetch-date"
]];
NSDate
*
expiryDate
=
[[[
NSDate
alloc
]
initWithTimeInterval
:
maxAge
sinceDate
:
fetchDate
]
autorelease
];
if
([
expiryDate
timeIntervalSinceNow
]
>=
0
)
{
[[
self
accessLock
]
unlock
];
return
YES
;
}
// RFC 2612 says max-age must override any Expires header
[[
self
accessLock
]
unlock
];
return
NO
;
}
}
// Look for an Expires header to see if the content is out of date
NSString
*
expires
=
[
cachedHeaders
objectForKey
:
@"Expires"
];
if
(
expires
)
{
if
([[
ASIHTTPRequest
dateFromRFC1123String
:
expires
]
timeIntervalSinceNow
]
>=
0
)
{
[[
self
accessLock
]
unlock
];
return
YES
;
}
}
// No explicit expiration time sent by the server
[[
self
accessLock
]
unlock
];
return
NO
;
...
...
Please
register
or
login
to post a comment