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-04 11:43:05 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b6663aaaf7819a6ae93a84307788ac59abe77e42
b6663aaa
1 parent
e357f3ca
Fix cache-control max-age header parsing
Closes gh-109
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletions
Classes/ASIDownloadCache.m
Classes/ASIHTTPRequest.m
Classes/Tests/ASIDownloadCacheTests.m
Classes/ASIDownloadCache.m
View file @
b6663aa
...
...
@@ -303,6 +303,7 @@ static NSString *permanentCacheFolder = @"PermanentStore";
NSString
*
cacheControl
=
[[
cachedHeaders
objectForKey
:
@"Cache-Control"
]
lowercaseString
];
if
(
cacheControl
)
{
NSScanner
*
scanner
=
[
NSScanner
scannerWithString
:
cacheControl
];
[
scanner
scanUpToString
:
@"max-age"
intoString
:
NULL
];
if
([
scanner
scanString
:
@"max-age"
intoString
:
NULL
])
{
[
scanner
scanString
:
@"="
intoString
:
NULL
];
NSTimeInterval
maxAge
=
0
;
...
...
Classes/ASIHTTPRequest.m
View file @
b6663aa
...
...
@@ -24,7 +24,7 @@
#import "ASIDataCompressor.h"
// Automatically set on build
NSString
*
ASIHTTPRequestVersion
=
@"v1.8-1
4 2010-12-02
"
;
NSString
*
ASIHTTPRequestVersion
=
@"v1.8-1
5 2010-12-04
"
;
NSString
*
const
NetworkRequestErrorDomain
=
@"ASIHTTPRequestErrorDomain"
;
...
...
Classes/Tests/ASIDownloadCacheTests.m
View file @
b6663aa
...
...
@@ -237,6 +237,21 @@
}
}
-
(
void
)
testMaxAgeParsing
{
[[
ASIDownloadCache
sharedCache
]
clearCachedResponsesForStoragePolicy
:
ASICacheForSessionDurationCacheStoragePolicy
];
[[
ASIDownloadCache
sharedCache
]
setDefaultCachePolicy
:
ASIUseDefaultCachePolicy
];
ASIHTTPRequest
*
request
=
[
ASIHTTPRequest
requestWithURL
:[
NSURL
URLWithString
:
@"http://asi/ASIHTTPRequest/tests/cache-control-max-age-parsing"
]];
[
request
setDownloadCache
:[
ASIDownloadCache
sharedCache
]];
[
request
startSynchronous
];
request
=
[
ASIHTTPRequest
requestWithURL
:[
NSURL
URLWithString
:
@"http://asi/ASIHTTPRequest/tests/cache-control-max-age-parsing"
]];
[
request
setDownloadCache
:[
ASIDownloadCache
sharedCache
]];
[
request
startSynchronous
];
BOOL
success
=
[
request
didUseCachedResponse
];
GHAssertTrue
(
success
,
@"Failed to use cached response"
);
}
-
(
void
)
testCustomExpiry
{
[[
ASIDownloadCache
sharedCache
]
clearCachedResponsesForStoragePolicy
:
ASICacheForSessionDurationCacheStoragePolicy
];
...
...
Please
register
or
login
to post a comment