Switch to using non-overlapping property and ivar for RKHTTPRequestOperation HTTP error. refs #1140

This commit is contained in:
Blake Watters
2013-03-10 14:52:50 -04:00
parent e62a9862d7
commit 2003715e2e

View File

@@ -194,7 +194,7 @@ static void *RKHTTPRequestOperationStartDate = &RKHTTPRequestOperationStartDate;
@end
@interface RKHTTPRequestOperation ()
@property (readwrite, nonatomic, strong) NSError *HTTPError;
@property (readwrite, nonatomic, strong) NSError *rkHTTPError;
@end
@implementation RKHTTPRequestOperation
@@ -234,7 +234,7 @@ static void *RKHTTPRequestOperationStartDate = &RKHTTPRequestOperationStartDate;
{
[self.lock lock];
if (!self.HTTPError && self.response) {
if (!self.rkHTTPError && self.response) {
if (![self hasAcceptableStatusCode] || ![self hasAcceptableContentType]) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
[userInfo setValue:self.responseString forKey:NSLocalizedRecoverySuggestionErrorKey];
@@ -245,16 +245,16 @@ static void *RKHTTPRequestOperationStartDate = &RKHTTPRequestOperationStartDate;
if (![self hasAcceptableStatusCode]) {
NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200;
[userInfo setValue:[NSString stringWithFormat:NSLocalizedString(@"Expected status code in (%@), got %d", nil), RKStringFromIndexSet(self.acceptableStatusCodes ?: [NSMutableIndexSet indexSet]), statusCode] forKey:NSLocalizedDescriptionKey];
self.HTTPError = [[NSError alloc] initWithDomain:RKErrorDomain code:NSURLErrorBadServerResponse userInfo:userInfo];
self.rkHTTPError = [[NSError alloc] initWithDomain:RKErrorDomain code:NSURLErrorBadServerResponse userInfo:userInfo];
} else if (![self hasAcceptableContentType] && self.response.statusCode != 204) {
// NOTE: 204 responses come back as text/plain, which we don't want
[userInfo setValue:[NSString stringWithFormat:NSLocalizedString(@"Expected content type %@, got %@", nil), self.acceptableContentTypes, [self.response MIMEType]] forKey:NSLocalizedDescriptionKey];
self.HTTPError = [[NSError alloc] initWithDomain:RKErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo];
self.rkHTTPError = [[NSError alloc] initWithDomain:RKErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo];
}
}
}
NSError *error = self.HTTPError ?: [super error];
NSError *error = self.rkHTTPError ?: [super error];
[self.lock unlock];
return error;
}