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-05-04 11:31:43 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9c38be5b9ad963e15528c49d47d2d05b031375fc
9c38be5b
1 parent
fd9af3d3
Add tests for expiry
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
3 deletions
Classes/ASIDownloadCache.m
Classes/ASIHTTPRequest.m
Classes/Tests/ASIDownloadCacheTests.m
Classes/ASIDownloadCache.m
View file @
9c38be5
...
...
@@ -27,13 +27,15 @@ static NSDateFormatter *rfc1123DateFormatter = nil;
if
(
self
==
[
ASIDownloadCache
class
])
{
rfc1123DateFormatter
=
[[
NSDateFormatter
alloc
]
init
];
[
rfc1123DateFormatter
setLocale
:[[[
NSLocale
alloc
]
initWithLocaleIdentifier
:
@"en_US_POSIX"
]
autorelease
]];
[
rfc1123DateFormatter
setDateFormat
:
@"EEE, dd MMM yyyy HH:mm:ss z"
];
[
rfc1123DateFormatter
setTimeZone
:[
NSTimeZone
timeZoneWithAbbreviation
:
@"GMT"
]];
[
rfc1123DateFormatter
setDateFormat
:
@"EEE, dd MMM yyyy HH:mm:ss 'GMT'"
];
}
}
-
(
id
)
init
{
self
=
[
super
init
];
[
self
setShouldRespectCacheControlHeaders
:
YES
];
[
self
setDefaultCachePolicy
:
ASIReloadIfDifferentCachePolicy
];
[
self
setDefaultCacheStoragePolicy
:
ASICacheForSessionDurationCacheStoragePolicy
];
[
self
setAccessLock
:[[[
NSRecursiveLock
alloc
]
init
]
autorelease
]];
...
...
Classes/ASIHTTPRequest.m
View file @
9c38be5
...
...
@@ -23,7 +23,7 @@
// Automatically set on build
NSString
*
ASIHTTPRequestVersion
=
@"v1.6.2-1
5 2010-05-03
"
;
NSString
*
ASIHTTPRequestVersion
=
@"v1.6.2-1
6 2010-05-04
"
;
NSString
*
const
NetworkRequestErrorDomain
=
@"ASIHTTPRequestErrorDomain"
;
...
...
Classes/Tests/ASIDownloadCacheTests.m
View file @
9c38be5
...
...
@@ -163,7 +163,28 @@
[
request
startSynchronous
];
success
=
!
[
request
didUseCachedResponse
];
GHAssertTrue
(
success
,
@"Should not have used data cached in default cache"
);
}
-
(
void
)
testExpiry
{
[[
ASIDownloadCache
sharedCache
]
clearCachedResponsesForStoragePolicy
:
ASICacheForSessionDurationCacheStoragePolicy
];
NSArray
*
headers
=
[
NSArray
arrayWithObjects
:
@"last-modified"
,
@"etag"
,
@"expires"
,
@"max-age"
,
nil
];
for
(
NSString
*
header
in
headers
)
{
ASIHTTPRequest
*
request
=
[
ASIHTTPRequest
requestWithURL
:[
NSURL
URLWithString
:[
NSString
stringWithFormat
:
@"http://asi/ASIHTTPRequest/tests/content-always-new/%@"
,
header
]]];
[
request
setDownloadCache
:[
ASIDownloadCache
sharedCache
]];
[
request
startSynchronous
];
if
([
header
isEqualToString
:
@"last-modified"
])
{
[
NSThread
sleepForTimeInterval
:
2
];
}
request
=
[
ASIHTTPRequest
requestWithURL
:[
NSURL
URLWithString
:[
NSString
stringWithFormat
:
@"http://asi/ASIHTTPRequest/tests/content-always-new/%@"
,
header
]]];
[
request
setDownloadCache
:[
ASIDownloadCache
sharedCache
]];
[
request
startSynchronous
];
BOOL
success
=
!
[
request
didUseCachedResponse
];
GHAssertTrue
(
success
,
@"Cached data should have expired"
);
}
}
@end
...
...
Please
register
or
login
to post a comment