Permalink
Browse files

Add extern declaration to constants in RKRequestCache. fixes #649, #652

  • Loading branch information...
blakewatters committed Apr 12, 2012
1 parent 3eb4091 commit fd9ee9952c7d8f0dd883329626a7766336ea7868
Showing with 28 additions and 18 deletions.
  1. +19 −9 Code/Network/RKRequestCache.h
  2. +6 −6 Code/Network/RKRequestCache.m
  3. +3 −3 Code/Network/RKResponse.m
@@ -43,20 +43,30 @@ typedef enum {
/**
Location of session specific cache files within the Caches path.
*/
-NSString * const RKRequestCacheSessionCacheDirectory;
+extern NSString * const RKRequestCacheSessionCacheDirectory;
/**
Location of permanent cache files within the Caches path.
*/
-NSString * const RKRequestCachePermanentCacheDirectory;
+extern NSString * const RKRequestCachePermanentCacheDirectory;
-/**
- */
-NSString * const RKRequestCacheHeadersExtension;
-NSString * const RKRequestCacheDateHeaderKey;
-NSString * const RKRequestCacheStatusCodeKey;
-NSString * const RKRequestCacheMIMETypeKey;
-NSString * const RKRequestCacheURLKey;
+/**
+ @constant RKRequestCache Header Keys
+
+ Constants for accessing cache specific X-RESTKIT
+ headers used to store cache metadata within the cache entry.
+*/
+/** The key for accessing the date the entry was cached. **/
+extern NSString * const RKRequestCacheDateHeaderKey;
+
+/** The key for accessing the status code of the cached request. **/
+extern NSString * const RKRequestCacheStatusCodeHeadersKey;
+
+/** The key for accessing the MIME Type of the cached request. **/
+extern NSString * const RKRequestCacheMIMETypeHeadersKey;
+
+/** The key for accessing the URL of the cached request. **/
+extern NSString * const RKRequestCacheURLHeadersKey;
/**
Stores and retrieves cache entries for RestKit request objects.
@@ -29,9 +29,9 @@
NSString * const RKRequestCachePermanentCacheDirectory = @"PermanentStore";
NSString * const RKRequestCacheHeadersExtension = @"headers";
NSString * const RKRequestCacheDateHeaderKey = @"X-RESTKIT-CACHEDATE";
-NSString * const RKRequestCacheStatusCodeKey = @"X-RESTKIT-CACHED-RESPONSE-CODE";
-NSString * const RKRequestCacheMIMETypeKey = @"X-RESTKIT-CACHED-MIME-TYPE";
-NSString * const RKRequestCacheURLKey = @"X-RESTKIT-CACHED-URL";
+NSString * const RKRequestCacheStatusCodeHeadersKey = @"X-RESTKIT-CACHED-RESPONSE-CODE";
+NSString * const RKRequestCacheMIMETypeHeadersKey = @"X-RESTKIT-CACHED-MIME-TYPE";
+NSString * const RKRequestCacheURLHeadersKey = @"X-RESTKIT-CACHED-URL";
static NSDateFormatter* __rfc1123DateFormatter;
@@ -118,13 +118,13 @@ - (void)storeResponse:(RKResponse*)response forRequest:(RKRequest*)request {
forKey:RKRequestCacheDateHeaderKey];
// Cache status code
[headers setObject:[NSNumber numberWithInteger:urlResponse.statusCode]
- forKey:RKRequestCacheStatusCodeKey];
+ forKey:RKRequestCacheStatusCodeHeadersKey];
// Cache MIME Type
[headers setObject:urlResponse.MIMEType
- forKey:RKRequestCacheMIMETypeKey];
+ forKey:RKRequestCacheMIMETypeHeadersKey];
// Cache URL
[headers setObject:[urlResponse.URL absoluteString]
- forKey:RKRequestCacheURLKey];
+ forKey:RKRequestCacheURLHeadersKey];
// Save
[_cache writeDictionary:headers withCacheKey:[cacheKey stringByAppendingPathExtension:RKRequestCacheHeadersExtension]];
}
@@ -292,21 +292,21 @@ - (BOOL)wasLoadedFromCache {
- (NSURL*)URL {
if ([self wasLoadedFromCache]) {
- return [NSURL URLWithString:[_responseHeaders valueForKey:RKRequestCacheURLKey]];
+ return [NSURL URLWithString:[_responseHeaders valueForKey:RKRequestCacheURLHeadersKey]];
}
return [_httpURLResponse URL];
}
- (NSString*)MIMEType {
if ([self wasLoadedFromCache]) {
- return [_responseHeaders valueForKey:RKRequestCacheMIMETypeKey];
+ return [_responseHeaders valueForKey:RKRequestCacheMIMETypeHeadersKey];
}
return [_httpURLResponse MIMEType];
}
- (NSInteger)statusCode {
if ([self wasLoadedFromCache]) {
- return [[_responseHeaders valueForKey:RKRequestCacheStatusCodeKey] intValue];
+ return [[_responseHeaders valueForKey:RKRequestCacheStatusCodeHeadersKey] intValue];
}
return ([_httpURLResponse respondsToSelector:@selector(statusCode)] ? [_httpURLResponse statusCode] : 200);
}

0 comments on commit fd9ee99

Please sign in to comment.