Converting int to NSUInteger for instances of manually checking status code in AFHTTPRequestOperation
This commit is contained in:
parent
ea2ef1b34d
commit
384df960ac
2 changed files with 5 additions and 7 deletions
|
|
@ -127,7 +127,7 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
|
|||
- (NSError *)error {
|
||||
if (self.response && !self.HTTPError) {
|
||||
if (![self hasAcceptableStatusCode]) {
|
||||
int statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? [self.response statusCode] : 200;
|
||||
NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200;
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
[userInfo setValue:[NSString stringWithFormat:NSLocalizedString(@"Expected status code in (%@), got %d", nil), AFStringFromIndexSet([[self class] acceptableStatusCodes]), statusCode] forKey:NSLocalizedDescriptionKey];
|
||||
[userInfo setValue:self.responseString forKey:NSLocalizedRecoverySuggestionErrorKey];
|
||||
|
|
@ -170,7 +170,7 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
|
|||
}
|
||||
|
||||
- (BOOL)hasAcceptableStatusCode {
|
||||
int statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? [self.response statusCode] : 200;
|
||||
NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200;
|
||||
return ![[self class] acceptableStatusCodes] || [[[self class] acceptableStatusCodes] containsIndex:statusCode];
|
||||
}
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
// 206 = Partial Content.
|
||||
long long totalContentLength = self.response.expectedContentLength;
|
||||
long long fileOffset = 0;
|
||||
int statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? [self.response statusCode] : 200;
|
||||
NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200;
|
||||
if (statusCode != 206) {
|
||||
if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) {
|
||||
[self.outputStream setProperty:[NSNumber numberWithInteger:0] forKey:NSStreamFileCurrentOffsetKey];
|
||||
|
|
@ -287,7 +287,7 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
self.outputStream = [NSOutputStream outputStreamToMemory];
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
NSString *contentRange = [self.response.allHeaderFields valueForKey:@"Content-Range"];
|
||||
if ([contentRange hasPrefix:@"bytes"]) {
|
||||
NSArray *bytes = [contentRange componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" -/"]];
|
||||
|
|
|
|||
|
|
@ -87,8 +87,6 @@ extern NSString * const AFNetworkingOperationDidFinishNotification;
|
|||
- `-copy` and `-copyWithZone:` return a new operation with the `NSURLRequest` of the original. So rather than an exact copy of the operation at that particular instant, the copying mechanism returns a completely new instance, which can be useful for retrying operations.
|
||||
- A copy of an operation will not include the `outputStream` of the original.
|
||||
- Operation copies do not include `completionBlock`. `completionBlock` often strongly captures a reference to `self`, which, perhaps surprisingly, would otherwise point to the _original_ operation when copied.
|
||||
|
||||
@warning Attempting to load a `file://` URL in iOS 4 may result in an `NSInvalidArgumentException`, caused by the connection returning `NSURLResponse` rather than `NSHTTPURLResponse`, which is the behavior as of iOS 5.
|
||||
*/
|
||||
@interface AFURLConnectionOperation : NSOperation <NSCoding, NSCopying>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue