Merge Request Queue (See issue #75):

* Introduces RKRequestCache for cacheing responses (supports ETag conditional GET, use cache if available, use cache on error, etc.) closes #75
    * Updates to Three20 layer to eliminate need for intermediary TTTableItem classes closes #76
    * Fixes to ensure iOS 3.x compatability:
        * Switched compiler to Clang
        * Updated conditional checks for UIBackgroundTask symbols to ensure runtime safety on iOS 3.x
        * Removed unnecessary linkage against UIKit and CoreFoundation from library targets
    * Fix for issue where RKRequest objects could become stuck in infinite loop within RKRequestQueue loadNextInQueue if you start
      a request and then cancel immediately. On cancel only decrement loadCount if the request has start loading. refs #122
This commit is contained in:
Blake Watters
2011-06-08 14:39:38 -04:00
parent 9416ad9cf6
commit f2ceefa012
42 changed files with 1829 additions and 268 deletions

View File

@@ -14,6 +14,8 @@
#import <CoreData/CoreData.h>
#import "RKRequestSerializable.h"
@class RKRequestCache;
/**
* HTTP methods for requests
*/
@@ -24,6 +26,28 @@ typedef enum RKRequestMethod {
RKRequestMethodDELETE
} RKRequestMethod;
/**
* Cache policy for determining how to use RKCache
*/
typedef enum {
// Never use the cache
RKRequestCachePolicyNone = 0,
// Load from the cache when we are offline
RKRequestCachePolicyLoadIfOffline = 1 << 0,
// Load from the cache if we encounter an error
RKRequestCachePolicyLoadOnError = 1 << 1,
// Load from the cache if we have data stored and the server returns a 304 (not modified) response
RKRequestCachePolicyEtag = 1 << 2,
// Load from the cache if we have data stored
RKRequestCachePolicyEnabled = 1 << 3,
RKRequestCachePolicyDefault = RKRequestCachePolicyEtag
} RKRequestCachePolicy;
/**
* Background Request Policy
*
@@ -55,9 +79,11 @@ typedef enum RKRequestBackgroundPolicy {
RKRequestMethod _method;
BOOL _isLoading;
BOOL _isLoaded;
RKRequestCachePolicy _cachePolicy;
BOOL _sentSynchronously;
BOOL _forceBasicAuthentication;
RKRequestBackgroundPolicy _backgroundPolicy;
RKRequestCache* _cache;
#if TARGET_OS_IPHONE
UIBackgroundTaskIdentifier _backgroundTaskIdentifier;
@@ -137,6 +163,11 @@ typedef enum RKRequestBackgroundPolicy {
*/
@property(nonatomic, readonly) NSString* HTTPMethod;
@property (nonatomic, readonly) NSString* cacheKey;
@property (nonatomic, assign) RKRequestCachePolicy cachePolicy;
@property (nonatomic, retain) RKRequestCache* cache;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////