Skip to content

Commit eabde28

Browse files
committed
Minor refactoring to AFHTTPRequestOperation
1 parent 0c25bce commit eabde28

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

AFNetworking/AFHTTPRequestOperation.m

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
@interface AFHTTPRequestOperation ()
2626
@property (readwrite, nonatomic, retain) NSError *HTTPError;
27-
@property (readonly, nonatomic, assign) BOOL hasContent;
2827
@end
2928

3029
@implementation AFHTTPRequestOperation
@@ -62,7 +61,7 @@ - (NSError *)error {
6261
[userInfo setValue:[self.request URL] forKey:NSURLErrorFailingURLErrorKey];
6362

6463
self.HTTPError = [[[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorBadServerResponse userInfo:userInfo] autorelease];
65-
} else if ([self hasContent] && ![self hasAcceptableContentType]) { // Don't invalidate content type if there is no content
64+
} else if ([self.responseData length] > 0 && ![self hasAcceptableContentType]) { // Don't invalidate content type if there is no content
6665
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
6766
[userInfo setValue:[NSString stringWithFormat:NSLocalizedString(@"Expected content type %@, got %@", nil), self.acceptableContentTypes, [self.response MIMEType]] forKey:NSLocalizedDescriptionKey];
6867
[userInfo setValue:[self.request URL] forKey:NSURLErrorFailingURLErrorKey];
@@ -71,17 +70,13 @@ - (NSError *)error {
7170
}
7271
}
7372

74-
if (_HTTPError) {
75-
return _HTTPError;
73+
if (self.HTTPError) {
74+
return self.HTTPError;
7675
} else {
7776
return [super error];
7877
}
7978
}
8079

81-
- (BOOL)hasContent {
82-
return [self.responseData length] > 0;
83-
}
84-
8580
- (BOOL)hasAcceptableStatusCode {
8681
return !self.acceptableStatusCodes || [self.acceptableStatusCodes containsIndex:[self.response statusCode]];
8782
}

0 commit comments

Comments
 (0)