From 59b54cadfd3b1092ce27ff5e4ece7081622d6c53 Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Wed, 13 Nov 2013 11:20:57 +0000 Subject: [PATCH] Added postDataEncodingHandler and cacheHeaders to copy, mutableCopy and copyForRetry methods These properties were not being copied, and caused unexpected behaviour or a crash in the cast of the cacheHeaders when retrying network operations --- MKNetworkKit/MKNetworkOperation.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MKNetworkKit/MKNetworkOperation.m b/MKNetworkKit/MKNetworkOperation.m index f6341d0..11fceb1 100644 --- a/MKNetworkKit/MKNetworkOperation.m +++ b/MKNetworkKit/MKNetworkOperation.m @@ -412,6 +412,7 @@ - (instancetype)copyWithZone:(NSZone *)zone MKNetworkOperation *theCopy = [[[self class] allocWithZone:zone] init]; // use designated initializer theCopy.postDataEncoding = _postDataEncoding; + [theCopy setPostDataEncodingHandler:[self.postDataEncodingHandler copy]]; [theCopy setStringEncoding:self.stringEncoding]; [theCopy setUniqueId:[self.uniqueId copy]]; @@ -438,6 +439,7 @@ - (instancetype)copyWithZone:(NSZone *)zone [theCopy setDownloadStreams:[self.downloadStreams copy]]; [theCopy setCachedResponse:[self.cachedResponse copy]]; [theCopy setCacheHandlingBlock:self.cacheHandlingBlock]; + [theCopy setCacheHeaders: [self.cacheHeaders copy]]; [theCopy setStartPosition:self.startPosition]; [theCopy setCredentialPersistence:self.credentialPersistence]; @@ -450,6 +452,7 @@ - (instancetype)mutableCopyWithZone:(NSZone *)zone MKNetworkOperation *theCopy = [[[self class] allocWithZone:zone] init]; // use designated initializer theCopy.postDataEncoding = _postDataEncoding; + [theCopy setPostDataEncodingHandler:[self.postDataEncodingHandler mutableCopy]]; [theCopy setStringEncoding:self.stringEncoding]; [theCopy setUniqueId:[self.uniqueId copy]]; @@ -476,6 +479,7 @@ - (instancetype)mutableCopyWithZone:(NSZone *)zone [theCopy setDownloadStreams:[self.downloadStreams mutableCopy]]; [theCopy setCachedResponse:[self.cachedResponse mutableCopy]]; [theCopy setCacheHandlingBlock:self.cacheHandlingBlock]; + [theCopy setCacheHeaders: [self.cacheHeaders mutableCopy]]; [theCopy setStartPosition:self.startPosition]; [theCopy setCredentialPersistence:self.credentialPersistence]; @@ -494,6 +498,7 @@ - (instancetype)copyForRetry [theCopy setStartPosition:0]; theCopy.postDataEncoding = _postDataEncoding; + [theCopy setPostDataEncodingHandler:[self.postDataEncodingHandler copy]]; [theCopy setStringEncoding:self.stringEncoding]; [theCopy setUniqueId:[self.uniqueId copy]]; [theCopy setRequest:[self.request copy]]; @@ -514,6 +519,7 @@ - (instancetype)copyForRetry [theCopy setDownloadStreams:[self.downloadStreams mutableCopy]]; [theCopy setCachedResponse:[self.cachedResponse mutableCopy]]; [theCopy setCacheHandlingBlock:self.cacheHandlingBlock]; + [theCopy setCacheHeaders: [self.cacheHeaders mutableCopy]]; [theCopy setCredentialPersistence:self.credentialPersistence]; return theCopy;