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-03 19:10:06 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fd9af3d350991c8d31ea7f528e1afe9f77fa8f4e
fd9af3d3
1 parent
ac122df6
Fix iPhone builds
General cleanup
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
4 deletions
Classes/ASIDownloadCache.m
Classes/ASIHTTPRequest.m
ASIDownloadCacheTests.h → Classes/Tests/ASIDownloadCacheTests.h
ASIDownloadCacheTests.m → Classes/Tests/ASIDownloadCacheTests.m
Mac.xcodeproj/project.pbxproj
iPhone.xcodeproj/project.pbxproj
Classes/ASIDownloadCache.m
View file @
fd9af3d
...
...
@@ -14,6 +14,7 @@ static ASIDownloadCache *sharedCache = nil;
static
NSString
*
sessionCacheFolder
=
@"SessionStore"
;
static
NSString
*
permanentCacheFolder
=
@"PermanentStore"
;
static
NSDateFormatter
*
rfc1123DateFormatter
=
nil
;
@interface
ASIDownloadCache
()
+
(
NSString
*
)
keyForRequest
:
(
ASIHTTPRequest
*
)
request
;
...
...
@@ -21,6 +22,15 @@ static NSString *permanentCacheFolder = @"PermanentStore";
@implementation
ASIDownloadCache
+
(
void
)
initialize
{
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"
];
}
}
-
(
id
)
init
{
self
=
[
super
init
];
...
...
@@ -109,13 +119,14 @@ static NSString *permanentCacheFolder = @"PermanentStore";
[
responseHeaders
removeObjectForKey
:
@"Content-Encoding"
];
}
// We use this special key to help expire the request when we get a max-age header
[
responseHeaders
setObject
:[
NSDate
date
]
forKey
:
@"X-ASIHTTPRequest-Fetch-date"
];
[
responseHeaders
setObject
:[
rfc1123DateFormatter
stringFromDate
:[
NSDate
date
]
]
forKey
:
@"X-ASIHTTPRequest-Fetch-date"
];
[
responseHeaders
writeToFile
:
metadataPath
atomically
:
NO
];
if
([
request
responseData
])
{
[[
request
responseData
]
writeToFile
:
dataPath
atomically
:
NO
];
}
else
if
([
request
downloadDestinationPath
])
{
[[
NSFileManager
defaultManager
]
copyPath
:[
request
downloadDestinationPath
]
toPath
:
dataPath
handler
:
nil
];
NSError
*
error
=
nil
;
[[
NSFileManager
defaultManager
]
copyItemAtPath
:[
request
downloadDestinationPath
]
toPath
:
dataPath
error
:&
error
];
}
[[
self
accessLock
]
unlock
];
...
...
@@ -208,8 +219,14 @@ static NSString *permanentCacheFolder = @"PermanentStore";
[
scanner
scanString
:
@"="
intoString
:
NULL
];
NSTimeInterval
maxAge
=
0
;
[
scanner
scanDouble
:
&
maxAge
];
NSDate
*
fetchDate
=
[[
cachedHeaders
objectForKey
:
@"X-ASIHTTPRequest-Fetch-date"
]
dateValue
];
NSDate
*
fetchDate
=
[
ASIHTTPRequest
dateFromRFC1123String
:[
cachedHeaders
objectForKey
:
@"X-ASIHTTPRequest-Fetch-date"
]];
#if (TARGET_OS_IPHONE && (!defined(__IPHONE_4_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_0)) || !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
NSDate
*
expiryDate
=
[
fetchDate
addTimeInterval
:
maxAge
];
#else
NSDate
*
expiryDate
=
[
fetchDate
dateByAddingTimeInterval
:
maxAge
];
#endif
if
([
expiryDate
timeIntervalSinceNow
]
<
0
)
{
return
NO
;
}
...
...
Classes/ASIHTTPRequest.m
View file @
fd9af3d
...
...
@@ -23,7 +23,7 @@
// Automatically set on build
NSString
*
ASIHTTPRequestVersion
=
@"v1.6.2-1
4
2010-05-03"
;
NSString
*
ASIHTTPRequestVersion
=
@"v1.6.2-1
5
2010-05-03"
;
NSString
*
const
NetworkRequestErrorDomain
=
@"ASIHTTPRequestErrorDomain"
;
...
...
ASIDownloadCacheTests.h
→
Classes/Tests/
ASIDownloadCacheTests.h
View file @
fd9af3d
File moved
ASIDownloadCacheTests.m
→
Classes/Tests/
ASIDownloadCacheTests.m
View file @
fd9af3d
File moved
Mac.xcodeproj/project.pbxproj
View file @
fd9af3d
This diff was suppressed by a .gitattributes entry.
iPhone.xcodeproj/project.pbxproj
View file @
fd9af3d
This diff was suppressed by a .gitattributes entry.
Please
register
or
login
to post a comment