diff --git a/RNCachingURLProtocol.h b/RNCachingURLProtocol.h index 0c24f5a..1667c84 100644 --- a/RNCachingURLProtocol.h +++ b/RNCachingURLProtocol.h @@ -60,8 +60,26 @@ #import +extern NSString *RNCachingURLProtocolWillStartRequestNotification; +extern NSString *RNCachingURLProtocolWillReceiveResponseNotification; +extern NSString *RNCachingURLProtocolWillFailWithErrorNotification; +extern NSString *RNCachingURLProtocolWillRedirectNotification; +extern NSString *RNCachingURLProtocolWillReceiveDataNotification; +extern NSString *RNCachingURLProtocolWillFinishNotification; +extern NSString *RNCachingURLProtocolWillStopNotification; + +extern NSString *RNCachingURLProtocolRequestKey; // NSURLRequest +extern NSString *RNCachingURLProtocolRedirectRequestKey; // NSURLRequest +extern NSString *RNCachingURLProtocolResponseKey; // NSURLResponse +extern NSString *RNCachingURLProtocolErrorKey; // NSError +extern NSString *RNCachingURLProtocolDataChunkKey; // NSData +extern NSString *RNCachingURLProtocolEnabledKey; // NSNumber (BOOL) + @interface RNCachingURLProtocol : NSURLProtocol ++ (BOOL)enabled; ++ (void)setEnabled:(BOOL)enabled; + - (NSString *)cachePathForRequest:(NSURLRequest *)aRequest; - (BOOL) useCache; diff --git a/RNCachingURLProtocol.m b/RNCachingURLProtocol.m index fe63444..2fbe0ee 100644 --- a/RNCachingURLProtocol.m +++ b/RNCachingURLProtocol.m @@ -28,6 +28,21 @@ #import "RNCachingURLProtocol.h" #import "Reachability.h" +NSString *RNCachingURLProtocolWillStartRequestNotification = @"RNCachingURLProtocolWillStartRequestNotification"; +NSString *RNCachingURLProtocolWillReceiveResponseNotification = @"RNCachingURLProtocolWillReceiveResponseNotification"; +NSString *RNCachingURLProtocolWillFailWithErrorNotification = @"RNCachingURLProtocolWillFailWithErrorNotification"; +NSString *RNCachingURLProtocolWillRedirectNotification = @"RNCachingURLProtocolWillRedirectNotification"; +NSString *RNCachingURLProtocolWillReceiveDataNotification = @"RNCachingURLProtocolWillReceiveDataNotification"; +NSString *RNCachingURLProtocolWillFinishNotification = @"RNCachingURLProtocolWillFinishNotification"; +NSString *RNCachingURLProtocolWillStopNotification = @"RNCachingURLProtocolWillStopNotification"; + +NSString *RNCachingURLProtocolRequestKey = @"RNCachingURLProtocolRequest"; +NSString *RNCachingURLProtocolRedirectRequestKey = @"RNCachingURLProtocolRedirectRequest"; +NSString *RNCachingURLProtocolResponseKey = @"RNCachingURLProtocolResponse"; +NSString *RNCachingURLProtocolErrorKey = @"RNCachingURLProtocolError"; +NSString *RNCachingURLProtocolDataChunkKey = @"RNCachingURLProtocolDataChunk"; +NSString *RNCachingURLProtocolEnabledKey = @"RNCachingURLProtocolEnabled"; + #define WORKAROUND_MUTABLE_COPY_LEAK 1 #if WORKAROUND_MUTABLE_COPY_LEAK @@ -51,14 +66,29 @@ @interface RNCachingURLProtocol () //