From c92f306c6d17e4071f42761024d2001753f1a6d3 Mon Sep 17 00:00:00 2001 From: Tomohisa Takaoka Date: Fri, 9 Nov 2012 14:23:51 -0800 Subject: [PATCH 0001/1434] Issue: Timeout when buffer ends during ending boundry --- AFNetworking/AFHTTPClient.m | 53 ++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 96a70609f1..d1491d9e3e 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -28,15 +28,15 @@ #import #ifdef _SYSTEMCONFIGURATION_H - #import - #import - #import - #import - #import +#import +#import +#import +#import +#import #endif #if __IPHONE_OS_VERSION_MIN_REQUIRED - #import +#import #endif #ifdef _SYSTEMCONFIGURATION_H @@ -107,7 +107,7 @@ - (id)initWithField:(id)field value:(id)value { if (!self) { return nil; } - + self.field = field; self.value = value; @@ -146,7 +146,7 @@ - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; if([value isKindOfClass:[NSDictionary class]]) { - // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries + // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(caseInsensitiveCompare:)]; [[[value allKeys] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]] enumerateObjectsUsingBlock:^(id nestedKey, NSUInteger idx, BOOL *stop) { id nestedValue = [value objectForKey:nestedKey]; @@ -210,7 +210,7 @@ + (AFHTTPClient *)clientWithBaseURL:(NSURL *)url { - (id)initWithBaseURL:(NSURL *)url { NSParameterAssert(url); - + self = [super init]; if (!self) { return nil; @@ -317,7 +317,7 @@ - (void)startMonitoringNetworkReachability { } self.networkReachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [[self.baseURL host] UTF8String]); - + __weak __typeof(&*self)weakSelf = self; AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status){ __strong __typeof(&*weakSelf)strongSelf = weakSelf; @@ -460,7 +460,7 @@ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]); NSMutableURLRequest *request = [self requestWithMethod:method path:path parameters:nil]; - + __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:request stringEncoding:self.stringEncoding]; if (parameters) { @@ -518,7 +518,7 @@ - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation { - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path -{ +{ NSString *URLStringToMatched = [[[self requestWithMethod:(method ?: @"GET") path:path parameters:nil] URL] absoluteString]; for (NSOperation *operation in [self.operationQueue operations]) { @@ -657,8 +657,8 @@ - (id)initWithCoder:(NSCoder *)aDecoder { return nil; } - self.stringEncoding = (NSStringEncoding)[aDecoder decodeIntegerForKey:@"stringEncoding"]; - self.parameterEncoding = (AFHTTPClientParameterEncoding)[aDecoder decodeIntegerForKey:@"parameterEncoding"]; + self.stringEncoding = [aDecoder decodeIntegerForKey:@"stringEncoding"]; + self.parameterEncoding = [aDecoder decodeIntegerForKey:@"parameterEncoding"]; self.registeredHTTPOperationClassNames = [aDecoder decodeObjectForKey:@"registeredHTTPOperationClassNames"]; self.defaultHeaders = [aDecoder decodeObjectForKey:@"defaultHeaders"]; @@ -824,7 +824,7 @@ - (void)appendPartWithFileData:(NSData *)data NSParameterAssert(name); NSParameterAssert(fileName); NSParameterAssert(mimeType); - + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; @@ -836,7 +836,7 @@ - (void)appendPartWithFormData:(NSData *)data name:(NSString *)name { NSParameterAssert(name); - + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"]; @@ -907,7 +907,7 @@ - (id)initWithStringEncoding:(NSStringEncoding)encoding { return nil; } - self.stringEncoding = encoding; + self.stringEncoding = encoding; self.HTTPBodyParts = [NSMutableArray array]; self.numberOfBytesInPacket = NSIntegerMax; @@ -920,7 +920,7 @@ - (void)setInitialAndFinalBoundaries { bodyPart.hasInitialBoundary = NO; bodyPart.hasFinalBoundary = NO; } - + [[self.HTTPBodyParts objectAtIndex:0] setHasInitialBoundary:YES]; [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES]; } @@ -940,7 +940,6 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { if ([self streamStatus] == NSStreamStatusClosed) { return 0; } - NSInteger bytesRead = 0; while ((NSUInteger)bytesRead < MIN(length, self.numberOfBytesInPacket)) { @@ -955,7 +954,6 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { } } } - return bytesRead; } @@ -975,7 +973,7 @@ - (void)open { } self.streamStatus = NSStreamStatusOpen; - + [self setInitialAndFinalBoundaries]; self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; } @@ -1034,6 +1032,7 @@ - (BOOL)_setCFClientFlags:(CFOptionFlags)inFlags AFHeaderPhase = 2, AFBodyPhase = 3, AFFinalBoundaryPhase = 4, + AFEndPhase = 5, } AFHTTPBodyPartReadPhase; @interface AFHTTPBodyPart () { @@ -1067,7 +1066,7 @@ - (void)dealloc { if (_inputStream) { [_inputStream close]; _inputStream = nil; - } + } } - (NSString *)stringForHeaders { @@ -1098,6 +1097,9 @@ - (unsigned long long)contentLength { } - (BOOL)hasBytesAvailable { + if (_phase == AFFinalBoundaryPhase) { + return YES; + } switch (self.inputStream.streamStatus) { case NSStreamStatusNotOpen: case NSStreamStatusOpening: @@ -1114,7 +1116,6 @@ - (BOOL)hasBytesAvailable { - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { NSInteger bytesRead = 0; - if (_phase == AFEncapsulationBoundaryPhase) { NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary() : AFMultipartFormEncapsulationBoundary()) dataUsingEncoding:self.stringEncoding]; bytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)]; @@ -1137,9 +1138,9 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { if (_phase == AFFinalBoundaryPhase) { NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding] : [NSData data]); + bytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)]; } - return bytesRead; } @@ -1178,11 +1179,13 @@ - (BOOL)transitionToNextPhase { [self.inputStream close]; _phase = AFFinalBoundaryPhase; break; + case AFFinalBoundaryPhase: + _phase = AFEndPhase; + break; default: _phase = AFEncapsulationBoundaryPhase; break; } - _phaseReadOffset = 0; return YES; From 31758693335b36b4f3cc9a03119dda861eb09f41 Mon Sep 17 00:00:00 2001 From: Nick Forge Date: Wed, 21 Nov 2012 15:46:19 +1100 Subject: [PATCH 0002/1434] Fixed retain cycles in AFImageRequestOperation.m and AFHTTPClient.m caused by strong references within blocks These retain cycles started showing up as compiler warnings after upgrading to Xcode 4.6DP --- AFNetworking/AFHTTPClient.m | 3 ++- AFNetworking/AFImageRequestOperation.m | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 96a70609f1..e3439da6ab 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -566,8 +566,9 @@ - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations for (AFHTTPRequestOperation *operation in operations) { AFCompletionBlock originalCompletionBlock = [operation.completionBlock copy]; + __weak AFHTTPRequestOperation *weakOperation = operation; operation.completionBlock = ^{ - dispatch_queue_t queue = operation.successCallbackQueue ?: dispatch_get_main_queue(); + dispatch_queue_t queue = weakOperation.successCallbackQueue ?: dispatch_get_main_queue(); dispatch_group_async(dispatchGroup, queue, ^{ if (originalCompletionBlock) { originalCompletionBlock(); diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index f4f724a6e6..5c24c791da 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -82,7 +82,7 @@ + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)ur dispatch_async(image_request_operation_processing_queue(), ^(void) { UIImage *processedImage = imageProcessingBlock(image); - dispatch_async(requestOperation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) { + dispatch_async(operation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) { success(operation.request, operation.response, processedImage); }); }); @@ -113,7 +113,7 @@ + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)ur dispatch_async(image_request_operation_processing_queue(), ^(void) { NSImage *processedImage = imageProcessingBlock(image); - dispatch_async(requestOperation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) { + dispatch_async(operation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) { success(operation.request, operation.response, processedImage); }); }); From 3486a008a1fd1348d0f2fe748a5e23933d94647a Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 17:48:42 +1100 Subject: [PATCH 0003/1434] Fixing warnings: implicit conversion changes signedness: 'NSInteger' (aka 'long') to 'unsigned long' [-Werror,-Wsign-conversion] --- AFNetworking/AFHTTPClient.m | 16 ++++++++-------- AFNetworking/AFURLConnectionOperation.m | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 98c574e2d3..997b22ec2a 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -653,7 +653,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder { return nil; } - self.stringEncoding = [aDecoder decodeIntegerForKey:@"stringEncoding"]; + self.stringEncoding = (NSStringEncoding)[aDecoder decodeIntegerForKey:@"stringEncoding"]; self.parameterEncoding = [aDecoder decodeIntegerForKey:@"parameterEncoding"]; self.registeredHTTPOperationClassNames = [aDecoder decodeObjectForKey:@"registeredHTTPOperationClassNames"]; self.defaultHeaders = [aDecoder decodeObjectForKey:@"defaultHeaders"]; @@ -663,7 +663,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder { - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.baseURL forKey:@"baseURL"]; - [aCoder encodeInteger:self.stringEncoding forKey:@"stringEncoding"]; + [aCoder encodeInteger:(NSInteger)self.stringEncoding forKey:@"stringEncoding"]; [aCoder encodeInteger:self.parameterEncoding forKey:@"parameterEncoding"]; [aCoder encodeObject:self.registeredHTTPOperationClassNames forKey:@"registeredHTTPOperationClassNames"]; [aCoder encodeObject:self.defaultHeaders forKey:@"defaultHeaders"]; @@ -945,7 +945,7 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { break; } } else { - bytesRead += [self.currentHTTPBodyPart read:&buffer[bytesRead] maxLength:length - bytesRead]; + bytesRead += [self.currentHTTPBodyPart read:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; if (self.delay > 0.0f) { [NSThread sleepForTimeInterval:self.delay]; } @@ -1113,17 +1113,17 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { if (_phase == AFEncapsulationBoundaryPhase) { NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary() : AFMultipartFormEncapsulationBoundary()) dataUsingEncoding:self.stringEncoding]; - bytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)]; + bytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; } if (_phase == AFHeaderPhase) { NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; - bytesRead += [self readData:headersData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)]; + bytesRead += [self readData:headersData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; } if (_phase == AFBodyPhase) { if ([self.inputStream hasBytesAvailable]) { - bytesRead += [self.inputStream read:&buffer[bytesRead] maxLength:(length - bytesRead)]; + bytesRead += [self.inputStream read:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; } if (![self.inputStream hasBytesAvailable]) { @@ -1133,7 +1133,7 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { if (_phase == AFFinalBoundaryPhase) { NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding] : [NSData data]); - bytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)]; + bytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; } return bytesRead; @@ -1152,7 +1152,7 @@ - (NSInteger)readData:(NSData *)data [self transitionToNextPhase]; } - return range.length; + return (NSInteger)range.length; } - (BOOL)transitionToNextPhase { diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 74d0c0bb38..0d5eb14b49 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -526,7 +526,7 @@ - (void)connection:(NSURLConnection *)__unused connection { if (self.uploadProgress) { dispatch_async(dispatch_get_main_queue(), ^{ - self.uploadProgress(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + self.uploadProgress((NSUInteger)bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); }); } } From debd44290384238c83dd3ececd6093bf195697a5 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 18:03:34 +1100 Subject: [PATCH 0004/1434] Fixes warning: unused parameter 'x' [-Werror,-Wunused-parameter] --- AFNetworking/AFHTTPClient.m | 36 +++++++++++++-------------- AFNetworking/AFHTTPRequestOperation.m | 10 ++++---- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 997b22ec2a..9a54f4855a 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -146,11 +146,11 @@ - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; if([value isKindOfClass:[NSDictionary class]]) { - [value enumerateKeysAndObjectsUsingBlock:^(id nestedKey, id nestedValue, BOOL *stop) { + [value enumerateKeysAndObjectsUsingBlock:^(id nestedKey, id nestedValue, __unused BOOL *stop) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; }]; } else if([value isKindOfClass:[NSArray class]]) { - [value enumerateObjectsUsingBlock:^(id nestedValue, NSUInteger idx, BOOL *stop) { + [value enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; }]; } else { @@ -302,7 +302,7 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ return (__bridge_retained const void *)([(__bridge AFNetworkReachabilityStatusBlock)info copy]); } -static void AFNetworkReachabilityReleaseCallback(const void *info) {} +static void AFNetworkReachabilityReleaseCallback(__unused const void *info) {} - (void)startMonitoringNetworkReachability { [self stopMonitoringNetworkReachability]; @@ -569,7 +569,7 @@ - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations } __block NSUInteger numberOfFinishedOperations = 0; - [operations enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [operations enumerateObjectsUsingBlock:^(id obj, __unused NSUInteger idx, __unused BOOL *stop) { if ([(NSOperation *)obj isFinished]) { numberOfFinishedOperations++; } @@ -955,7 +955,7 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { return bytesRead; } -- (BOOL)getBuffer:(uint8_t **)buffer length:(NSUInteger *)len { +- (BOOL)getBuffer:(__unused uint8_t **)buffer length:(__unused NSUInteger *)len { return NO; } @@ -980,20 +980,20 @@ - (void)close { self.streamStatus = NSStreamStatusClosed; } -- (id)propertyForKey:(NSString *)key { +- (id)propertyForKey:(__unused NSString *)key { return nil; } -- (BOOL)setProperty:(id)property forKey:(NSString *)key { +- (BOOL)setProperty:(__unused id)property forKey:(__unused NSString *)key { return NO; } -- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop - forMode:(NSString *)mode +- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode {} -- (void)removeFromRunLoop:(NSRunLoop *)aRunLoop - forMode:(NSString *)mode +- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode {} - (unsigned long long)contentLength { @@ -1007,17 +1007,17 @@ - (unsigned long long)contentLength { #pragma mark - Undocumented CFReadStream Bridged Methods -- (void)_scheduleInCFRunLoop:(CFRunLoopRef)aRunLoop - forMode:(CFStringRef)aMode +- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode {} -- (void)_unscheduleFromCFRunLoop:(CFRunLoopRef)aRunLoop - forMode:(CFStringRef)aMode +- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode {} -- (BOOL)_setCFClientFlags:(CFOptionFlags)inFlags - callback:(CFReadStreamClientCallBack)inCallback - context:(CFStreamClientContext *)inContext { +- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags + callback:(__unused CFReadStreamClientCallBack)inCallback + context:(__unused CFStreamClientContext *)inContext { return NO; } diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 3e31962d18..2256d40fc4 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -38,7 +38,7 @@ NSArray *mediaRanges = [string componentsSeparatedByString:@","]; NSMutableSet *mutableContentTypes = [NSMutableSet setWithCapacity:mediaRanges.count]; - [mediaRanges enumerateObjectsUsingBlock:^(NSString *mediaRange, NSUInteger idx, BOOL *stop) { + [mediaRanges enumerateObjectsUsingBlock:^(NSString *mediaRange, __unused NSUInteger idx, __unused BOOL *stop) { NSRange parametersRange = [mediaRange rangeOfString:@";"]; if (parametersRange.location != NSNotFound) { mediaRange = [mediaRange substringToIndex:parametersRange.location]; @@ -271,7 +271,7 @@ + (NSIndexSet *)acceptableStatusCodes { + (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes { NSMutableIndexSet *mutableStatusCodes = [[NSMutableIndexSet alloc] initWithIndexSet:[self acceptableStatusCodes]]; [mutableStatusCodes addIndexes:statusCodes]; - AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(id _self) { + AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(__unused id _self) { return mutableStatusCodes; }); } @@ -283,7 +283,7 @@ + (NSSet *)acceptableContentTypes { + (void)addAcceptableContentTypes:(NSSet *)contentTypes { NSMutableSet *mutableContentTypes = [[NSMutableSet alloc] initWithSet:[self acceptableContentTypes] copyItems:YES]; [mutableContentTypes unionSet:contentTypes]; - AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(id _self) { + AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(__unused id _self) { return mutableContentTypes; }); } @@ -298,8 +298,8 @@ + (BOOL)canProcessRequest:(NSURLRequest *)request { #pragma mark - NSURLConnectionDelegate -- (void)connection:(NSURLConnection *)connection -didReceiveResponse:(NSURLResponse *)response +- (void)connection:(__unused NSURLConnection *)connection +didReceiveResponse:(__unused NSURLResponse *)response { self.response = (NSHTTPURLResponse *)response; From f9449753ffe1f5301e1670271a8b575209af2165 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 18:06:05 +1100 Subject: [PATCH 0005/1434] Fixes warning: property is assumed atomic by default [-Werror,-Wimplicit-atomic-properties] --- AFNetworking/AFHTTPRequestOperation.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 2256d40fc4..c67fe144d1 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -96,8 +96,8 @@ @interface AFHTTPRequestOperation () @property (readwrite, nonatomic, strong) NSURLRequest *request; @property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; @property (readwrite, nonatomic, strong) NSError *HTTPError; -@property (assign) long long totalContentLength; -@property (assign) long long offsetContentLength; +@property (atomic, assign) long long totalContentLength; +@property (atomic, assign) long long offsetContentLength; @end @implementation AFHTTPRequestOperation From 23b8fe33ba10eaed6f4d9bced62deea0b208fa1b Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 18:30:28 +1100 Subject: [PATCH 0006/1434] Fixes warning: weak receiver may be unpredictably null in ARC mode [-Werror,-Wreceiver-is-weak] --- AFNetworking/AFURLConnectionOperation.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 0d5eb14b49..44bc11d827 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -215,8 +215,10 @@ - (void)setCompletionBlock:(void (^)(void))block { } else { __weak __typeof(&*self)weakSelf = self; [super setCompletionBlock:^ { + __typeof(&*weakSelf) operation = weakSelf; + block(); - [weakSelf setCompletionBlock:nil]; + [operation setCompletionBlock:nil]; }]; } [self.lock unlock]; From 3997dbb7e9d942edff59ff66d484b6b74556a868 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 18:46:04 +1100 Subject: [PATCH 0007/1434] Fixes warning: multiple methods named 'selector' found [-Werror,-Wstrict-selector-match] --- AFNetworking/AFHTTPClient.m | 6 ++++-- AFNetworking/AFHTTPRequestOperation.m | 4 ++++ AFNetworking/AFURLConnectionOperation.m | 10 +++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 9a54f4855a..b366be27e2 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -150,7 +150,8 @@ - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; }]; } else if([value isKindOfClass:[NSArray class]]) { - [value enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { + NSArray *array = value; + [array enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; }]; } else { @@ -295,7 +296,8 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ block(status); } - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; } static const void * AFNetworkReachabilityRetainCallback(const void *info) { diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index c67fe144d1..2525cbf235 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -30,6 +30,10 @@ #define AF_CAST_TO_BLOCK __bridge void * #endif +// We do a little bit of duck typing in this file which can trigger this warning. Turn it off for this source file. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wstrict-selector-match" + NSSet * AFContentTypesFromHTTPHeader(NSString *string) { if (!string) { return nil; diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 44bc11d827..7c756cfdba 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -310,12 +310,14 @@ - (void)setState:(AFOperationState)state { [self didChangeValueForKey:oldStateKey]; [self didChangeValueForKey:newStateKey]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + switch (state) { case AFOperationExecutingState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; + [notificationCenter postNotificationName:AFNetworkingOperationDidStartNotification object:self]; break; case AFOperationFinishedState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; break; default: break; @@ -351,7 +353,9 @@ - (void)pause { if ([self isExecuting]) { [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; } self.state = AFOperationPausedState; From f4d25341cf31522750b32b0a2c33eeb9dff6ae9b Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Thu, 29 Nov 2012 19:08:41 +1100 Subject: [PATCH 0008/1434] Fixing tabs/spaces whitespace inconsistency. --- AFNetworking/AFHTTPClient.m | 4 ++-- AFNetworking/AFURLConnectionOperation.m | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index b366be27e2..e8898d199d 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -150,7 +150,7 @@ - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; }]; } else if([value isKindOfClass:[NSArray class]]) { - NSArray *array = value; + NSArray *array = value; [array enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; }]; @@ -296,7 +296,7 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ block(status); } - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; } diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 7c756cfdba..1f90136fbe 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -310,7 +310,7 @@ - (void)setState:(AFOperationState)state { [self didChangeValueForKey:oldStateKey]; [self didChangeValueForKey:newStateKey]; - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; switch (state) { case AFOperationExecutingState: @@ -354,7 +354,7 @@ - (void)pause { if ([self isExecuting]) { [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; } From d8b4dcb349e34994c37da3f4520a1120107bc471 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 17:47:14 +1100 Subject: [PATCH 0009/1434] Fixes warning: 'macro' is not defined, evaluates to 0 --- AFNetworking/AFImageRequestOperation.h | 18 +++++++++--------- .../AFNetworkActivityIndicatorManager.h | 2 +- .../AFNetworkActivityIndicatorManager.m | 2 +- AFNetworking/AFURLConnectionOperation.h | 2 +- AFNetworking/AFURLConnectionOperation.m | 8 ++++---- AFNetworking/UIImageView+AFNetworking.m | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/AFNetworking/AFImageRequestOperation.h b/AFNetworking/AFImageRequestOperation.h index d028a84db1..b906783a44 100644 --- a/AFNetworking/AFImageRequestOperation.h +++ b/AFNetworking/AFImageRequestOperation.h @@ -25,9 +25,9 @@ #import -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) #import #endif @@ -54,13 +54,13 @@ /** An image constructed from the response data. If an error occurs during the request, `nil` will be returned, and the `error` property will be set to the error. */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) @property (readonly, nonatomic, strong) UIImage *responseImage; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) @property (readonly, nonatomic, strong) NSImage *responseImage; #endif -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) /** The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. */ @@ -75,10 +75,10 @@ @return A new image request operation */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(UIImage *image))success; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(NSImage *image))success; #endif @@ -93,12 +93,12 @@ @return A new image request operation */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest imageProcessingBlock:(UIImage *(^)(UIImage *image))imageProcessingBlock success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elifdef __MAC_OS_X_VERSION_MIN_REQUIRED + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest imageProcessingBlock:(NSImage *(^)(NSImage *image))imageProcessingBlock success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.h b/AFNetworking/AFNetworkActivityIndicatorManager.h index 2b4d54c590..7b6cbe760e 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.h +++ b/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -24,7 +24,7 @@ #import -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import /** diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.m b/AFNetworking/AFNetworkActivityIndicatorManager.m index a67cfec848..afb6f00070 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.m +++ b/AFNetworking/AFNetworkActivityIndicatorManager.m @@ -24,7 +24,7 @@ #import "AFHTTPRequestOperation.h" -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; @interface AFNetworkActivityIndicatorManager () diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 3a391b0a3f..a6be720a00 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -184,7 +184,7 @@ @param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified. */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler; #endif diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 1f90136fbe..25432a96f4 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -21,7 +21,7 @@ // THE SOFTWARE. #import "AFURLConnectionOperation.h" -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import #endif @@ -39,7 +39,7 @@ typedef signed short AFOperationState; -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) typedef UIBackgroundTaskIdentifier AFBackgroundTaskIdentifier; #else typedef id AFBackgroundTaskIdentifier; @@ -196,7 +196,7 @@ - (void)dealloc { _outputStream = nil; } -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) if (_backgroundTaskIdentifier) { [[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier]; _backgroundTaskIdentifier = UIBackgroundTaskInvalid; @@ -249,7 +249,7 @@ - (void)setOutputStream:(NSOutputStream *)outputStream { [self didChangeValueForKey:@"outputStream"]; } -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler { [self.lock lock]; if (!self.backgroundTaskIdentifier) { diff --git a/AFNetworking/UIImageView+AFNetworking.m b/AFNetworking/UIImageView+AFNetworking.m index 1294d61d38..f399c0e620 100644 --- a/AFNetworking/UIImageView+AFNetworking.m +++ b/AFNetworking/UIImageView+AFNetworking.m @@ -23,7 +23,7 @@ #import #import -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import "UIImageView+AFNetworking.h" @interface AFImageCache : NSCache From 72ab802a2dbdbcad85749d0b832b29c7bc23015d Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 18:02:15 +1100 Subject: [PATCH 0010/1434] Fixes warning: atomic by default property 'X' has a user defined getter (property should be marked 'atomic' if this is intended) [-Werror,-Wcustom-atomic-properties] --- AFNetworking/AFHTTPRequestOperation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPRequestOperation.h b/AFNetworking/AFHTTPRequestOperation.h index b7207f1369..d6776b3926 100644 --- a/AFNetworking/AFHTTPRequestOperation.h +++ b/AFNetworking/AFHTTPRequestOperation.h @@ -44,12 +44,12 @@ /** A Boolean value that corresponds to whether the status code of the response is within the specified set of acceptable status codes. Returns `YES` if `acceptableStatusCodes` is `nil`. */ -@property (readonly) BOOL hasAcceptableStatusCode; +@property (nonatomic, readonly) BOOL hasAcceptableStatusCode; /** A Boolean value that corresponds to whether the MIME type of the response is among the specified set of acceptable content types. Returns `YES` if `acceptableContentTypes` is `nil`. */ -@property (readonly) BOOL hasAcceptableContentType; +@property (nonatomic, readonly) BOOL hasAcceptableContentType; /** The callback dispatch queue on success. If `NULL` (default), the main queue is used. From 692f7126ca8baa4e564b153073d5907903839a4b Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 18:04:44 +1100 Subject: [PATCH 0011/1434] Fixes warning: 'response' was marked unused but was used [-Werror,-Wused-but-marked-unused] --- AFNetworking/AFHTTPRequestOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 2525cbf235..0e5f076e16 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -303,7 +303,7 @@ + (BOOL)canProcessRequest:(NSURLRequest *)request { #pragma mark - NSURLConnectionDelegate - (void)connection:(__unused NSURLConnection *)connection -didReceiveResponse:(__unused NSURLResponse *)response +didReceiveResponse:(NSURLResponse *)response { self.response = (NSHTTPURLResponse *)response; From b75c673a2c28233884a0d88fe85311173727c244 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 18:12:47 +1100 Subject: [PATCH 0012/1434] Fixes warning: 'X' is not defined, evaluates to 0 [-Werror,-Wundef] --- AFNetworking/AFHTTPClient.m | 6 +++--- AFNetworking/AFImageRequestOperation.m | 24 ++++++++++++------------ AFNetworking/AFNetworking.h | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index e8898d199d..c55ce85af2 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -35,7 +35,7 @@ #import #endif -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import #endif @@ -230,10 +230,10 @@ - (id)initWithBaseURL:(NSURL *)url { NSString *preferredLanguageCodes = [[NSLocale preferredLanguages] componentsJoinedByString:@", "]; [self setDefaultHeader:@"Accept-Language" value:[NSString stringWithFormat:@"%@, en-us;q=0.8", preferredLanguageCodes]]; -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0f)]]; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]]; #endif diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index f4f724a6e6..cf24f31966 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -32,20 +32,20 @@ static dispatch_queue_t image_request_operation_processing_queue() { } @interface AFImageRequestOperation () -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) @property (readwrite, nonatomic, strong) UIImage *responseImage; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) @property (readwrite, nonatomic, strong) NSImage *responseImage; #endif @end @implementation AFImageRequestOperation @synthesize responseImage = _responseImage; -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) @synthesize imageScale = _imageScale; #endif -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(UIImage *image))success { @@ -55,7 +55,7 @@ + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)ur } } failure:nil]; } -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(NSImage *image))success { @@ -68,7 +68,7 @@ + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)ur #endif -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success @@ -99,7 +99,7 @@ + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)ur return requestOperation; } -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest imageProcessingBlock:(NSImage *(^)(NSImage *))imageProcessingBlock success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success @@ -137,7 +137,7 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest { return nil; } -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) self.imageScale = [[UIScreen mainScreen] scale]; #endif @@ -145,7 +145,7 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest { } -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - (UIImage *)responseImage { if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) { UIImage *image = [UIImage imageWithData:self.responseData]; @@ -168,7 +168,7 @@ - (void)setImageScale:(CGFloat)imageScale { self.responseImage = nil; } -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) - (NSImage *)responseImage { if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) { // Ensure that the image is set to it's correct pixel width and height @@ -216,9 +216,9 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio } } else { if (success) { -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) UIImage *image = nil; -#elif __MAC_OS_X_VERSION_MIN_REQUIRED +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) NSImage *image = nil; #endif diff --git a/AFNetworking/AFNetworking.h b/AFNetworking/AFNetworking.h index 49e596cc01..c0e8e6255e 100644 --- a/AFNetworking/AFNetworking.h +++ b/AFNetworking/AFNetworking.h @@ -36,7 +36,7 @@ #import "AFImageRequestOperation.h" -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #import "AFNetworkActivityIndicatorManager.h" #import "UIImageView+AFNetworking.h" #endif From b64c6bd846ab0e216c9495f4efdd9f7860906915 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 18:13:43 +1100 Subject: [PATCH 0013/1434] Fixes warning: atomic by default property 'X' has a user defined getter (property should be marked 'atomic' if this is intended) [-Werror,-Wcustom-atomic-properties] --- AFNetworking/AFHTTPClient.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index c55ce85af2..28ee57e3f3 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -729,8 +729,8 @@ @interface AFHTTPBodyPart : NSObject @property (nonatomic, assign) BOOL hasInitialBoundary; @property (nonatomic, assign) BOOL hasFinalBoundary; -@property (readonly, getter = hasBytesAvailable) BOOL bytesAvailable; -@property (readonly) unsigned long long contentLength; +@property (nonatomic, readonly, getter = hasBytesAvailable) BOOL bytesAvailable; +@property (nonatomic, readonly) unsigned long long contentLength; - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length; @end @@ -738,8 +738,8 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length; @interface AFMultipartBodyStream : NSInputStream @property (nonatomic, assign) NSUInteger numberOfBytesInPacket; @property (nonatomic, assign) NSTimeInterval delay; -@property (readonly) unsigned long long contentLength; -@property (readonly, getter = isEmpty) BOOL empty; +@property (nonatomic, readonly) unsigned long long contentLength; +@property (nonatomic, readonly, getter = isEmpty) BOOL empty; - (id)initWithStringEncoding:(NSStringEncoding)encoding; - (void)setInitialAndFinalBoundaries; From d38895e5d83bda19e874a5b6618d8a0e0eff8d9c Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 30 Nov 2012 18:14:26 +1100 Subject: [PATCH 0014/1434] Fixes warning: enumeration value 'AFFinalBoundaryPhase' not explicitly handled in switch [-Werror,-Wswitch-enum] --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 28ee57e3f3..2548253c51 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1176,7 +1176,7 @@ - (BOOL)transitionToNextPhase { [self.inputStream close]; _phase = AFFinalBoundaryPhase; break; - default: + case AFFinalBoundaryPhase: _phase = AFEncapsulationBoundaryPhase; break; } From eaa1252d40c1b27954d5867eb09c74f80bfb9f76 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 30 Nov 2012 13:37:07 -0800 Subject: [PATCH 0015/1434] Adding top-level group for source files --- .../contents.xcworkspacedata | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/AFNetworking.xcworkspace/contents.xcworkspacedata b/AFNetworking.xcworkspace/contents.xcworkspacedata index a31cc09900..66991fbcad 100644 --- a/AFNetworking.xcworkspace/contents.xcworkspacedata +++ b/AFNetworking.xcworkspace/contents.xcworkspacedata @@ -1,6 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 607e91b5b8de785881bc0d989c384922986fb170 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 30 Nov 2012 14:11:59 -0800 Subject: [PATCH 0016/1434] Adding responseStringEncoding property to AFURLConnectionOperation --- AFNetworking/AFURLConnectionOperation.h | 9 +++++++-- AFNetworking/AFURLConnectionOperation.m | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 3a391b0a3f..813c9565ed 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -114,11 +114,16 @@ /** The string representation of the response data. - - @discussion This method uses the string encoding of the response, or if UTF-8 if not specified, to construct a string from the response data. */ @property (readonly, nonatomic, copy) NSString *responseString; +/** + The string encoding of the response. + + @discussion If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. + */ +@property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; + ///------------------------ /// @name Accessing Streams ///------------------------ diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index db8c0fedb1..9440d0139e 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -115,6 +115,7 @@ @interface AFURLConnectionOperation () @property (readwrite, nonatomic, strong) NSError *error; @property (readwrite, nonatomic, strong) NSData *responseData; @property (readwrite, nonatomic, copy) NSString *responseString; +@property (readwrite, nonatomic, assign) NSStringEncoding responseStringEncoding; @property (readwrite, nonatomic, assign) long long totalBytesRead; @property (readwrite, nonatomic, assign) AFBackgroundTaskIdentifier backgroundTaskIdentifier; @property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress; @@ -139,6 +140,7 @@ @implementation AFURLConnectionOperation @synthesize error = _error; @synthesize responseData = _responseData; @synthesize responseString = _responseString; +@synthesize responseStringEncoding = _responseStringEncoding; @synthesize totalBytesRead = _totalBytesRead; @dynamic inputStream; @synthesize outputStream = _outputStream; @@ -326,6 +328,16 @@ - (void)setState:(AFOperationState)state { - (NSString *)responseString { [self.lock lock]; if (!_responseString && self.response && self.responseData) { + self.responseString = [[NSString alloc] initWithData:self.responseData encoding:self.responseStringEncoding]; + } + [self.lock unlock]; + + return _responseString; +} + +- (NSStringEncoding)responseStringEncoding { + [self.lock lock]; + if (!_responseStringEncoding) { NSStringEncoding stringEncoding = NSUTF8StringEncoding; if (self.response.textEncodingName) { CFStringEncoding IANAEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName); @@ -334,11 +346,11 @@ - (NSString *)responseString { } } - self.responseString = [[NSString alloc] initWithData:self.responseData encoding:stringEncoding]; + self.responseStringEncoding = stringEncoding; } [self.lock unlock]; - return _responseString; + return _responseStringEncoding; } - (void)pause { From 09cf2d39e22aa6f2f43f56924bebd365e48886d7 Mon Sep 17 00:00:00 2001 From: Mathijs Kadijk Date: Fri, 30 Nov 2012 14:12:59 -0800 Subject: [PATCH 0017/1434] [Issue #660] Add workaround for NSJSONSerialization crash with Unicode character escapes in JSON response Signed-off-by: Mattt Thompson --- AFNetworking/AFJSONRequestOperation.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 77ac8eb25b..78f3bb2f66 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -67,7 +67,10 @@ - (id)responseJSON { if ([self.responseData length] == 0) { self.responseJSON = nil; } else { - self.responseJSON = [NSJSONSerialization JSONObjectWithData:self.responseData options:self.JSONReadingOptions error:&error]; + // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character + // See http://stackoverflow.com/a/12843465/157142 + NSData *JSONData = [self.responseString dataUsingEncoding:self.responseStringEncoding]; + self.responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:self.JSONReadingOptions error:&error]; } self.JSONError = error; From 99c58dcf08c4ffd02f6374c5312afaf3f212f83f Mon Sep 17 00:00:00 2001 From: Basil Shkara Date: Fri, 30 Nov 2012 14:22:05 -0800 Subject: [PATCH 0018/1434] [Issue #652] Adding early return in -startMonitoringNetworkReachability if network reachability object could not be created (i.e. invalid hostnames) Signed-off-by: Mattt Thompson --- AFNetworking/AFHTTPClient.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index bce7f1c098..ae57a3b180 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -317,6 +317,10 @@ - (void)startMonitoringNetworkReachability { } self.networkReachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [[self.baseURL host] UTF8String]); + + if (!self.networkReachability) { + return; + } __weak __typeof(&*self)weakSelf = self; AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status){ From d3cb65c0874cf76a9a4ea6524fd515671b114b18 Mon Sep 17 00:00:00 2001 From: Sebastian Ludwig Date: Fri, 30 Nov 2012 14:40:53 -0800 Subject: [PATCH 0019/1434] [Issue #651] Adding workaround for Rails behavior of returning a single space in head :ok responses, which is interpreted as invalid input by NSJSONSerialization Signed-off-by: Mattt Thompson --- AFNetworking/AFJSONRequestOperation.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 78f3bb2f66..5401cbf1b5 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -64,7 +64,9 @@ - (id)responseJSON { if (!_responseJSON && [self.responseData length] > 0 && [self isFinished] && !self.JSONError) { NSError *error = nil; - if ([self.responseData length] == 0) { + // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization. + // See https://github.com/rails/rails/issues/1742 + if ([self.responseData length] == 0 || [self.responseString isEqualToString:@" "]) { self.responseJSON = nil; } else { // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character From fa0fc535a149a35f4a69b4e082b1a8cccad0d002 Mon Sep 17 00:00:00 2001 From: Jonathan Beilin Date: Mon, 17 Dec 2012 10:31:00 -0800 Subject: [PATCH 0020/1434] Adding assertion for empty data in -appendPartWithHeaders:body: --- AFNetworking/AFHTTPClient.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 502c587f1e..dd897212b8 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -851,6 +851,8 @@ - (void)appendPartWithFormData:(NSData *)data - (void)appendPartWithHeaders:(NSDictionary *)headers body:(NSData *)body { + NSParameterAssert(body); + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; bodyPart.stringEncoding = self.stringEncoding; bodyPart.headers = headers; From 474a940414500fe3b24b91e5f7f09806d65418bb Mon Sep 17 00:00:00 2001 From: Jesse Collis Date: Mon, 17 Dec 2012 22:59:43 +1100 Subject: [PATCH 0021/1434] Fixes a handful of -Wstrict-selector-match warnings raised by Xcode 4.6DP3. As noted by @0xced, casting satisfies the compiler without changing the behaviour. --- AFNetworking/AFJSONRequestOperation.m | 2 +- AFNetworking/AFPropertyListRequestOperation.m | 2 +- AFNetworking/AFURLConnectionOperation.m | 2 +- AFNetworking/AFXMLRequestOperation.m | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 5401cbf1b5..459b1d8aad 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -45,7 +45,7 @@ + (AFJSONRequestOperation *)JSONRequestOperationWithRequest:(NSURLRequest *)urlR success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure { - AFJSONRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest]; + AFJSONRequestOperation *requestOperation = [(AFJSONRequestOperation *)[self alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { if (success) { success(operation.request, operation.response, responseObject); diff --git a/AFNetworking/AFPropertyListRequestOperation.m b/AFNetworking/AFPropertyListRequestOperation.m index 21961d0526..6885def538 100644 --- a/AFNetworking/AFPropertyListRequestOperation.m +++ b/AFNetworking/AFPropertyListRequestOperation.m @@ -47,7 +47,7 @@ + (AFPropertyListRequestOperation *)propertyListRequestOperationWithRequest:(NSU success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure { - AFPropertyListRequestOperation *requestOperation = [[self alloc] initWithRequest:request]; + AFPropertyListRequestOperation *requestOperation = [(AFPropertyListRequestOperation *)[self alloc] initWithRequest:request]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { if (success) { success(operation.request, operation.response, responseObject); diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 78a6226a9b..059430aa57 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -652,7 +652,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { #pragma mark - NSCopying - (id)copyWithZone:(NSZone *)zone { - AFURLConnectionOperation *operation = [[[self class] allocWithZone:zone] initWithRequest:self.request]; + AFURLConnectionOperation *operation = [(AFURLConnectionOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request]; operation.uploadProgress = self.uploadProgress; operation.downloadProgress = self.downloadProgress; diff --git a/AFNetworking/AFXMLRequestOperation.m b/AFNetworking/AFXMLRequestOperation.m index d8de09afee..2157eebd78 100644 --- a/AFNetworking/AFXMLRequestOperation.m +++ b/AFNetworking/AFXMLRequestOperation.m @@ -52,7 +52,7 @@ + (AFXMLRequestOperation *)XMLParserRequestOperationWithRequest:(NSURLRequest *) success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure { - AFXMLRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest]; + AFXMLRequestOperation *requestOperation = [(AFXMLRequestOperation *)[self alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { if (success) { success(operation.request, operation.response, responseObject); From 7134e9612f0cd2865a4624000147f62e74e5fe45 Mon Sep 17 00:00:00 2001 From: Daniel Tull Date: Wed, 19 Dec 2012 14:47:49 +0000 Subject: [PATCH 0022/1434] Cause a failure when an operation is cancelled, fixes #657 --- AFNetworking/AFHTTPRequestOperation.m | 4 ---- AFNetworking/AFImageRequestOperation.m | 4 ---- AFNetworking/AFJSONRequestOperation.m | 6 +----- AFNetworking/AFPropertyListRequestOperation.m | 6 +----- AFNetworking/AFURLConnectionOperation.m | 13 ++++++++----- AFNetworking/AFXMLRequestOperation.m | 6 +----- 6 files changed, 11 insertions(+), 28 deletions(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 247571339c..091f05bf3f 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -273,10 +273,6 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" self.completionBlock = ^{ - if ([self isCancelled]) { - return; - } - if (self.error) { if (failure) { dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index cf24f31966..5346998a00 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -203,10 +203,6 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" self.completionBlock = ^ { - if ([self isCancelled]) { - return; - } - dispatch_async(image_request_operation_processing_queue(), ^(void) { if (self.error) { if (failure) { diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 5401cbf1b5..8fd0de03cb 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -104,11 +104,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" - self.completionBlock = ^ { - if ([self isCancelled]) { - return; - } - + self.completionBlock = ^ { if (self.error) { if (failure) { dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ diff --git a/AFNetworking/AFPropertyListRequestOperation.m b/AFNetworking/AFPropertyListRequestOperation.m index 21961d0526..d45438934b 100644 --- a/AFNetworking/AFPropertyListRequestOperation.m +++ b/AFNetworking/AFPropertyListRequestOperation.m @@ -108,11 +108,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" - self.completionBlock = ^ { - if ([self isCancelled]) { - return; - } - + self.completionBlock = ^ { if (self.error) { if (failure) { dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 78a6226a9b..14967058d4 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -453,15 +453,18 @@ - (void)cancel { } - (void)cancelConnection { + + NSDictionary *userInfo = nil; + if ([self.request URL]) { + userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; + } + self.error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; + if (self.connection) { [self.connection cancel]; // Manually send this delegate message since `[self.connection cancel]` causes the connection to never send another message to its delegate - NSDictionary *userInfo = nil; - if ([self.request URL]) { - userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; - } - [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]]; + [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.error]; } } diff --git a/AFNetworking/AFXMLRequestOperation.m b/AFNetworking/AFXMLRequestOperation.m index d8de09afee..fdb39061ed 100644 --- a/AFNetworking/AFXMLRequestOperation.m +++ b/AFNetworking/AFXMLRequestOperation.m @@ -140,11 +140,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" - self.completionBlock = ^ { - if ([self isCancelled]) { - return; - } - + self.completionBlock = ^ { dispatch_async(xml_request_operation_processing_queue(), ^(void) { NSXMLParser *XMLParser = self.responseXMLParser; From 0530c9c10735d7eb1aff8a9a04552a64204316de Mon Sep 17 00:00:00 2001 From: guykogus Date: Sun, 23 Dec 2012 10:59:56 +0200 Subject: [PATCH 0023/1434] Implemented usage of instancetype. --- AFNetworking/AFHTTPClient.h | 4 +-- AFNetworking/AFHTTPClient.m | 4 +-- AFNetworking/AFImageRequestOperation.h | 24 ++++++++--------- AFNetworking/AFImageRequestOperation.m | 26 +++++++++---------- AFNetworking/AFJSONRequestOperation.h | 6 ++--- AFNetworking/AFJSONRequestOperation.m | 6 ++--- .../AFNetworkActivityIndicatorManager.h | 2 +- .../AFNetworkActivityIndicatorManager.m | 2 +- AFNetworking/AFPropertyListRequestOperation.h | 6 ++--- AFNetworking/AFPropertyListRequestOperation.m | 8 +++--- AFNetworking/AFURLConnectionOperation.h | 2 +- AFNetworking/AFURLConnectionOperation.m | 2 +- AFNetworking/AFXMLRequestOperation.h | 12 ++++----- AFNetworking/AFXMLRequestOperation.m | 12 ++++----- 14 files changed, 58 insertions(+), 58 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 400bdfa2a3..0fba67c0ea 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -148,7 +148,7 @@ typedef enum { @return The newly-initialized HTTP client */ -+ (AFHTTPClient *)clientWithBaseURL:(NSURL *)url; ++ (instancetype)clientWithBaseURL:(NSURL *)url; /** Initializes an `AFHTTPClient` object with the specified base URL. @@ -159,7 +159,7 @@ typedef enum { @return The newly-initialized HTTP client */ -- (id)initWithBaseURL:(NSURL *)url; +- (instancetype)initWithBaseURL:(NSURL *)url; ///----------------------------------- /// @name Managing Reachability Status diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index dd897212b8..8117feafeb 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -205,11 +205,11 @@ @implementation AFHTTPClient @synthesize networkReachabilityStatusBlock = _networkReachabilityStatusBlock; #endif -+ (AFHTTPClient *)clientWithBaseURL:(NSURL *)url { ++ (instancetype)clientWithBaseURL:(NSURL *)url { return [[self alloc] initWithBaseURL:url]; } -- (id)initWithBaseURL:(NSURL *)url { +- (instancetype)initWithBaseURL:(NSURL *)url { NSParameterAssert(url); self = [super init]; diff --git a/AFNetworking/AFImageRequestOperation.h b/AFNetworking/AFImageRequestOperation.h index b4d0e5217b..d991b2509f 100644 --- a/AFNetworking/AFImageRequestOperation.h +++ b/AFNetworking/AFImageRequestOperation.h @@ -76,11 +76,11 @@ @return A new image request operation */ #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(UIImage *image))success; ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(UIImage *image))success; #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(NSImage *image))success; ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSImage *image))success; #endif /** @@ -94,15 +94,15 @@ @return A new image request operation */ #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest - imageProcessingBlock:(UIImage *(^)(UIImage *image))imageProcessingBlock - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + imageProcessingBlock:(UIImage *(^)(UIImage *image))imageProcessingBlock + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest - imageProcessingBlock:(NSImage *(^)(NSImage *image))imageProcessingBlock - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + imageProcessingBlock:(NSImage *(^)(NSImage *image))imageProcessingBlock + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; #endif @end diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index cf24f31966..eee438115e 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -46,8 +46,8 @@ @implementation AFImageRequestOperation #endif #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(UIImage *image))success ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(UIImage *image))success { return [self imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil success:^(NSURLRequest __unused *request, NSHTTPURLResponse __unused *response, UIImage *image) { if (success) { @@ -56,8 +56,8 @@ + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)ur } failure:nil]; } #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(NSImage *image))success ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSImage *image))success { return [self imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil success:^(NSURLRequest __unused *request, NSHTTPURLResponse __unused *response, NSImage *image) { if (success) { @@ -69,10 +69,10 @@ + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)ur #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest - imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure { AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { @@ -100,10 +100,10 @@ + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)ur return requestOperation; } #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest - imageProcessingBlock:(NSImage *(^)(NSImage *))imageProcessingBlock - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + imageProcessingBlock:(NSImage *(^)(NSImage *))imageProcessingBlock + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure { AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { @@ -131,7 +131,7 @@ + (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)ur } #endif -- (id)initWithRequest:(NSURLRequest *)urlRequest { +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { self = [super initWithRequest:urlRequest]; if (!self) { return nil; diff --git a/AFNetworking/AFJSONRequestOperation.h b/AFNetworking/AFJSONRequestOperation.h index 34acb4dd8e..d625cb2501 100644 --- a/AFNetworking/AFJSONRequestOperation.h +++ b/AFNetworking/AFJSONRequestOperation.h @@ -64,8 +64,8 @@ @return A new JSON request operation */ -+ (AFJSONRequestOperation *)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure; ++ (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure; @end diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 5401cbf1b5..9782c1e9fe 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -41,9 +41,9 @@ @implementation AFJSONRequestOperation @synthesize JSONReadingOptions = _JSONReadingOptions; @synthesize JSONError = _JSONError; -+ (AFJSONRequestOperation *)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure ++ (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure { AFJSONRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.h b/AFNetworking/AFNetworkActivityIndicatorManager.h index 7b6cbe760e..59cabcd230 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.h +++ b/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -58,7 +58,7 @@ @return The systemwide network activity indicator manager. */ -+ (AFNetworkActivityIndicatorManager *)sharedManager; ++ (instancetype)sharedManager; /** Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.m b/AFNetworking/AFNetworkActivityIndicatorManager.m index afb6f00070..8f4d8681b8 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.m +++ b/AFNetworking/AFNetworkActivityIndicatorManager.m @@ -42,7 +42,7 @@ @implementation AFNetworkActivityIndicatorManager @synthesize enabled = _enabled; @dynamic networkActivityIndicatorVisible; -+ (AFNetworkActivityIndicatorManager *)sharedManager { ++ (instancetype)sharedManager { static AFNetworkActivityIndicatorManager *_sharedManager = nil; static dispatch_once_t oncePredicate; dispatch_once(&oncePredicate, ^{ diff --git a/AFNetworking/AFPropertyListRequestOperation.h b/AFNetworking/AFPropertyListRequestOperation.h index c509274eca..04fe6223fa 100644 --- a/AFNetworking/AFPropertyListRequestOperation.h +++ b/AFNetworking/AFPropertyListRequestOperation.h @@ -61,8 +61,8 @@ @return A new property list request operation */ -+ (AFPropertyListRequestOperation *)propertyListRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure; ++ (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure; @end diff --git a/AFNetworking/AFPropertyListRequestOperation.m b/AFNetworking/AFPropertyListRequestOperation.m index 21961d0526..fd4fee2026 100644 --- a/AFNetworking/AFPropertyListRequestOperation.m +++ b/AFNetworking/AFPropertyListRequestOperation.m @@ -43,9 +43,9 @@ @implementation AFPropertyListRequestOperation @synthesize propertyListFormat = _propertyListFormat; @synthesize propertyListError = _propertyListError; -+ (AFPropertyListRequestOperation *)propertyListRequestOperationWithRequest:(NSURLRequest *)request - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure ++ (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)request + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure { AFPropertyListRequestOperation *requestOperation = [[self alloc] initWithRequest:request]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { @@ -61,7 +61,7 @@ + (AFPropertyListRequestOperation *)propertyListRequestOperationWithRequest:(NSU return requestOperation; } -- (id)initWithRequest:(NSURLRequest *)urlRequest { +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { self = [super initWithRequest:urlRequest]; if (!self) { return nil; diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 35489b6194..a2ee570430 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -153,7 +153,7 @@ @discussion This is the designated initializer. */ -- (id)initWithRequest:(NSURLRequest *)urlRequest; +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest; ///---------------------------------- /// @name Pausing / Resuming Requests diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 78a6226a9b..ecc9ef6c3c 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -173,7 +173,7 @@ + (NSThread *)networkRequestThread { return _networkRequestThread; } -- (id)initWithRequest:(NSURLRequest *)urlRequest { +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { self = [super init]; if (!self) { return nil; diff --git a/AFNetworking/AFXMLRequestOperation.h b/AFNetworking/AFXMLRequestOperation.h index 82624d0dfc..6a327f4f36 100644 --- a/AFNetworking/AFXMLRequestOperation.h +++ b/AFNetworking/AFXMLRequestOperation.h @@ -66,9 +66,9 @@ @return A new XML request operation */ -+ (AFXMLRequestOperation *)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure; ++ (instancetype)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure; #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED @@ -81,9 +81,9 @@ @return A new XML request operation */ -+ (AFXMLRequestOperation *)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure; ++ (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure; #endif @end diff --git a/AFNetworking/AFXMLRequestOperation.m b/AFNetworking/AFXMLRequestOperation.m index d8de09afee..0a29a7c490 100644 --- a/AFNetworking/AFXMLRequestOperation.m +++ b/AFNetworking/AFXMLRequestOperation.m @@ -48,9 +48,9 @@ @implementation AFXMLRequestOperation #endif @synthesize XMLError = _XMLError; -+ (AFXMLRequestOperation *)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure ++ (instancetype)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure { AFXMLRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { @@ -67,9 +67,9 @@ + (AFXMLRequestOperation *)XMLParserRequestOperationWithRequest:(NSURLRequest *) } #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED -+ (AFXMLRequestOperation *)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure ++ (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure { AFXMLRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, __unused id responseObject) { From 07c9f6c35861de64c3ae4ecb8a5aadd568db06cd Mon Sep 17 00:00:00 2001 From: Dustin Barker Date: Fri, 21 Dec 2012 17:35:13 -0800 Subject: [PATCH 0024/1434] Add optional SSL certificate pinning --- AFNetworking/AFURLConnectionOperation.m | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 78a6226a9b..b9bb79150f 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -173,6 +173,24 @@ + (NSThread *)networkRequestThread { return _networkRequestThread; } ++ (NSArray *)pinnedCertificates { + static NSArray *_pinnedCertificates = nil; + static dispatch_once_t oncePredicate; + + dispatch_once(&oncePredicate, ^{ + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; + NSMutableArray *certificates = [NSMutableArray array]; + for (NSString *path in paths) { + NSData *certificateData = [NSData dataWithContentsOfFile:path]; + [certificates addObject:certificateData]; + } + _pinnedCertificates = [[NSArray alloc] initWithArray:certificates]; + }); + + return _pinnedCertificates; +} + - (id)initWithRequest:(NSURLRequest *)urlRequest { self = [super init]; if (!self) { @@ -467,6 +485,25 @@ - (void)cancelConnection { #pragma mark - NSURLConnectionDelegate +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +-(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge +{ + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, 0); + NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); + + NSArray *pinnedCertificates = [[self class] pinnedCertificates]; + if ([pinnedCertificates containsObject:remoteCertificateData]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; + } + } +} +#endif + - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { From 46559bd6ca11dc343da9d155355a92de96ec00ad Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 26 Dec 2012 09:39:25 -0500 Subject: [PATCH 0025/1434] Minor refactoring and reformatting --- AFNetworking/AFURLConnectionOperation.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index b9bb79150f..96c27c6e26 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -175,9 +175,9 @@ + (NSThread *)networkRequestThread { + (NSArray *)pinnedCertificates { static NSArray *_pinnedCertificates = nil; - static dispatch_once_t oncePredicate; + static dispatch_once_t onceToken; - dispatch_once(&oncePredicate, ^{ + dispatch_once(&onceToken, ^{ NSBundle *bundle = [NSBundle bundleForClass:[self class]]; NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; NSMutableArray *certificates = [NSMutableArray array]; @@ -486,15 +486,15 @@ - (void)cancelConnection { #pragma mark - NSURLConnectionDelegate #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ --(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge +- (void)connection:(NSURLConnection *)connection +willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, 0); - NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); - - NSArray *pinnedCertificates = [[self class] pinnedCertificates]; - if ([pinnedCertificates containsObject:remoteCertificateData]) { + NSData *certificateData = (__bridge_transfer NSData *)SecCertificateCopyData(certificate); + + if ([[[self class] pinnedCertificates] containsObject:certificateData]) { NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; } else { From e75dea4fd11dac87443d7ca038584b0a186b3959 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 26 Dec 2012 09:57:15 -0500 Subject: [PATCH 0026/1434] Minor code formatting --- AFNetworking/AFURLConnectionOperation.m | 1 - 1 file changed, 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 6c685fe3ce..27fd7de6d8 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -471,7 +471,6 @@ - (void)cancel { } - (void)cancelConnection { - NSDictionary *userInfo = nil; if ([self.request URL]) { userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; From 732cd2da02cb4208c5b6a40fa53508cb95e4bf90 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 26 Dec 2012 10:29:57 -0500 Subject: [PATCH 0027/1434] [Issue #686][Issue #168] Adding userInfo @property /cc @tewha --- AFNetworking/AFURLConnectionOperation.h | 9 +++++++++ AFNetworking/AFURLConnectionOperation.m | 1 + 2 files changed, 10 insertions(+) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 35489b6194..94c07e8957 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -142,6 +142,15 @@ */ @property (nonatomic, strong) NSOutputStream *outputStream; +///--------------------------------------------- +/// @name Managing Request Operation Information +///--------------------------------------------- + +/** + The user info dictionary for the receiver. + */ +@property (nonatomic, strong) NSDictionary *userInfo; + ///------------------------------------------------------ /// @name Initializing an AFURLConnectionOperation Object ///------------------------------------------------------ diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index ac6bfd35ec..675476b52e 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -144,6 +144,7 @@ @implementation AFURLConnectionOperation @synthesize totalBytesRead = _totalBytesRead; @dynamic inputStream; @synthesize outputStream = _outputStream; +@synthesize userInfo = _userInfo; @synthesize backgroundTaskIdentifier = _backgroundTaskIdentifier; @synthesize uploadProgress = _uploadProgress; @synthesize downloadProgress = _downloadProgress; From 314afe9dc019c22c83e77c1dae2d52028dc3a953 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 26 Dec 2012 11:37:18 -0500 Subject: [PATCH 0028/1434] [Issue #696] Potentially fixing leak for reachability callback block --- AFNetworking/AFHTTPClient.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index dd897212b8..63410b42e7 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -308,7 +308,11 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ return (__bridge_retained const void *)([(__bridge AFNetworkReachabilityStatusBlock)info copy]); } -static void AFNetworkReachabilityReleaseCallback(__unused const void *info) {} +static void AFNetworkReachabilityReleaseCallback(const void *info) { + if (info) { + CFRelease(info); + } +} - (void)startMonitoringNetworkReachability { [self stopMonitoringNetworkReachability]; From 7b685fe35efd574fdd5b779c12ff2577f5a27814 Mon Sep 17 00:00:00 2001 From: Evadne Wu Date: Thu, 27 Dec 2012 12:19:13 -0500 Subject: [PATCH 0029/1434] dispatches network request start / end notifications asynchronously Signed-off-by: Mattt Thompson --- AFNetworking/AFURLConnectionOperation.m | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 675476b52e..e6cd7293ca 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -331,17 +331,19 @@ - (void)setState:(AFOperationState)state { _state = state; [self didChangeValueForKey:oldStateKey]; [self didChangeValueForKey:newStateKey]; - - switch (state) { - case AFOperationExecutingState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; - break; - case AFOperationFinishedState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; - break; - default: - break; - } + + dispatch_async(dispatch_get_main_queue(), ^{ + switch (state) { + case AFOperationExecutingState: + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; + break; + case AFOperationFinishedState: + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + break; + default: + break; + } + }); } [self.lock unlock]; } From a9b9ebee376058546837d5114cdbd9a114483729 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 27 Dec 2012 12:22:46 -0500 Subject: [PATCH 0030/1434] Asynchronously posting all notifications by dispatching to main --- AFNetworking/AFHTTPClient.m | 4 +++- AFNetworking/AFURLConnectionOperation.m | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index dd897212b8..3c896d98ca 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -301,7 +301,9 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ block(status); } - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; + }); } static const void * AFNetworkReachabilityRetainCallback(const void *info) { diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index e6cd7293ca..0d27490b0a 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -385,7 +385,10 @@ - (void)pause { if ([self isExecuting]) { [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + }); } self.state = AFOperationPausedState; From d4c4b2c30b903b9d7df19da7349f08be0e3020f1 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 27 Dec 2012 17:00:23 -0500 Subject: [PATCH 0031/1434] Updating Changelog for 1.1.0 --- CHANGES | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index f1895ad029..70f5a33340 100644 --- a/CHANGES +++ b/CHANGES @@ -1,12 +1,68 @@ -= master += 1.1.0 (2012-12-27) - * Moved __unused keywords for better Xcode indexing (Christian Rasmussen) + * Add optional SSL certificate pinning with `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` (Dustin Barker) - * Sorting dictionary keys with `caseInsensitiveCompare:` to ensure + * Add `responseStringEncoding` property to `AFURLConnectionOperation` (Mattt Thompson) + + * Add `userInfo` property to `AFURLConnectionOperation` (Mattt Thompson, Steven Fisher) + + * Change behavior to cause a failure when an operation is cancelled (Daniel Tull) + + * Change return type of class constructors to `instancetype` (@guykogus) + + * Change notifications to always being posted on an asynchronously-dispatched block run on the main queue (Evadne Wu, Mattt Thompson) + + * Change from NSLocalizedString to NSLocalizedStringFromTable with AFNetworking.strings table for localized strings (Cédric Luthi) + + * Change `-appendPartWithHeaders:body:` to add assertion handler for existence of body data parameter (Jonathan Beilin) + + * Change `AFHTTPRequestOperation -responseString` to follow guidelines from RFC 2616 regarding the use of string encoding when none is specified in the response (Jorge Bernal) + + * Change AFHTTPClient parameter serialization dictionary keys with `caseInsensitiveCompare:` to ensure deterministic ordering of query string parameters, which may otherwise cause ambiguous representations of nested parameters (James Coleman, Mattt Thompson) + * Fix -Wstrict-selector-match warnings raised by Xcode 4.6DP3 (Jesse Collis, Cédric Luthi) + + * Fix NSJSONSerialization crash with Unicode character escapes in JSON response (Mathijs Kadijk) + + * Fix issue with early return in -startMonitoringNetworkReachability if network reachability object could not be created (i.e. invalid hostnames) (Basil Shkara) + + * Fix retain cycles in AFImageRequestOperation.m and AFHTTPClient.m caused by strong references within blocks (Nick Forge) + + * Fix issue caused by Rails behavior of returning a single space in head :ok responses, which is interpreted as invalid (Sebastian Ludwig) + + * Fix issue in streaming multipart upload, where final encapsulation boundary would not be appended if it was larger than the available buffer, causing a potential timeout (Tomohisa Takaoka, David Kasper) + + * Fix memory leak of network reachability callback block (Mattt Thompson) + + * Fix `-initWithCoder:` for `AFURLConnectionOperation` and `AFHTTPClient` to cast scalar types (Mattt Thompson) + + * Fix bug in `-enqueueBatchOfHTTPRequestOperations:...` to by using `addOperations:waitUntilFinished:` instead of adding each operation individually. (Mattt Thompson) + + * Change `#warning` messages of checks for `CoreServices` and `MobileCoreServices` to message according to the build target platform (Mattt Thompson) + + * Change `AFQueryStringFromParametersWithEncoding` to create keys string representations using the description method as specified in documentation (Cédric Luthi) + + * Fix __unused keywords for better Xcode indexing (Christian Rasmussen) + + * Fix warning: unused parameter 'x' [-Werror,-Wunused-parameter] (Oliver Jones) + + * Fix warning: property is assumed atomic by default [-Werror,-Wimplicit-atomic-properties] (Oliver Jones) + + * Fix warning: weak receiver may be unpredictably null in ARC mode [-Werror,-Wreceiver-is-weak] (Oliver Jones) + + * Fix warning: multiple methods named 'selector' found [-Werror,-Wstrict-selector-match] (Oliver Jones) + + * Fix warning: 'macro' is not defined, evaluates to 0 (Oliver Jones) + + * Fix warning: atomic by default property 'X' has a user (Oliver Jones)defined getter (property should be marked 'atomic' if this is intended) [-Werror, -Wcustom-atomic-properties] (Oliver Jones) + + * Fix warning: 'response' was marked unused but was used [-Werror,-Wused-but-marked-unused] (Oliver Jones) + + * Fix warning: enumeration value 'AFFinalBoundaryPhase' not explicitly handled in switch [-Werror,-Wswitch-enum] (Oliver Jones) + = 1.0.1 / 2012-11-01 * Fix error in multipart upload streaming, where byte range at boundaries From 121ef7afa8ce1b1cefdc5312f7e9d75f5af65b8d Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 27 Dec 2012 17:01:06 -0500 Subject: [PATCH 0032/1434] Bumping version to 1.1.0 --- AFNetworking.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking.podspec b/AFNetworking.podspec index 5ebb028cfc..8c6affc7d0 100644 --- a/AFNetworking.podspec +++ b/AFNetworking.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = 'AFNetworking' - s.version = '1.0' + s.version = '1.1.0' s.license = 'MIT' s.summary = 'A delightful iOS and OS X networking framework.' s.homepage = 'https://github.com/AFNetworking/AFNetworking' s.authors = { 'Mattt Thompson' => 'm@mattt.me', 'Scott Raymond' => 'sco@gowalla.com' } - s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => '1.0' } + s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => '1.1.0' } s.source_files = 'AFNetworking' s.requires_arc = true From b1f9598ed24b1ec1b6f24b004578e6736590998b Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Fri, 28 Dec 2012 11:48:42 +0100 Subject: [PATCH 0033/1434] Adds SSLPinningMode to AFURLConnectionOperation and defaultSSLPinMode to AFHTTPClient. --- AFNetworking/AFHTTPClient.h | 8 ++++ AFNetworking/AFHTTPClient.m | 4 ++ AFNetworking/AFURLConnectionOperation.h | 14 ++++++ AFNetworking/AFURLConnectionOperation.m | 64 ++++++++++++++++++++++--- 4 files changed, 83 insertions(+), 7 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 68c6de8f64..79234b2562 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -23,6 +23,7 @@ #import #import +#import "AFURLConnectionOperation.h" /** `AFHTTPClient` captures the common patterns of communicating with an web application over HTTP. It encapsulates information like base URL, authorization credentials, and HTTP headers, and uses them to construct and manage the execution of HTTP request operations. @@ -137,6 +138,13 @@ typedef enum { @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; #endif +/** + Default SSL pinning mode for each `AFHTTPRequestOperation` which will be enqueued with `enqueueHTTPRequestOperation:`. + */ +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +@property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode defaultSSLPinMode; +#endif + ///--------------------------------------------- /// @name Creating and Initializing HTTP Clients ///--------------------------------------------- diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 3fec759b34..ceda84d325 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -524,6 +524,10 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR #pragma mark - - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation { +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ + operation.SSLPinningMode = self.defaultSSLPinMode; +#endif + [self.operationQueue addOperation:operation]; } diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 94c07e8957..47139acefc 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -24,6 +24,13 @@ #import +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +typedef enum { + AFURLConnectionOperationSSLPinningModeCertificate = 0, + AFURLConnectionOperationSSLPinningModePublicKey +} AFURLConnectionOperationSSLPinningMode; +#endif + /** `AFURLConnectionOperation` is a subclass of `NSOperation` that implements `NSURLConnection` delegate methods. @@ -124,6 +131,13 @@ */ @property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; +/** + The pinning mode which will be used for SSL connections. + */ +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +@property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode SSLPinningMode; +#endif + ///------------------------ /// @name Accessing Streams ///------------------------ diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 0d27490b0a..0a590a2449 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -192,6 +192,36 @@ + (NSArray *)pinnedCertificates { return _pinnedCertificates; } ++ (NSArray *)pinnedPublicKeys { + static NSArray *_pinnedPublicKeys = nil; + static dispatch_once_t onceToken; + + dispatch_once(&onceToken, ^{ + NSArray *pinnedCertificates = [self pinnedCertificates]; + NSMutableArray *publicKeys = [NSMutableArray array]; + + for (NSData *data in pinnedCertificates) { + SecCertificateRef allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)data); + NSParameterAssert(allowedCertificate); + + SecPolicyRef policy = SecPolicyCreateBasicX509(); + SecTrustRef allowedTrust = NULL; + OSStatus status = SecTrustCreateWithCertificates(allowedCertificate, policy, &allowedTrust); + NSAssert(status == noErr, @"SecTrustCreateWithCertificates error: %ld", status); + + SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust); + [publicKeys addObject:(__bridge_transfer id)allowedPublicKey]; + + CFRelease(allowedTrust); + CFRelease(allowedCertificate); + } + + _pinnedPublicKeys = [[NSArray alloc] initWithArray:publicKeys]; + }); + + return _pinnedPublicKeys; +} + - (id)initWithRequest:(NSURLRequest *)urlRequest { self = [super init]; if (!self) { @@ -499,14 +529,34 @@ - (void)connection:(NSURLConnection *)connection { if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, 0); - NSData *certificateData = (__bridge_transfer NSData *)SecCertificateCopyData(certificate); - if ([[[self class] pinnedCertificates] containsObject:certificateData]) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] cancelAuthenticationChallenge:challenge]; + switch (self.SSLPinningMode) { + case AFURLConnectionOperationSSLPinningModeCertificate: { + SecCertificateRef serverCertificate = SecTrustGetCertificateAtIndex(serverTrust, 0); + NSData *certificateData = (__bridge_transfer NSData *)SecCertificateCopyData(serverCertificate); + + if ([[[self class] pinnedCertificates] containsObject:certificateData]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; + } + break; + } case AFURLConnectionOperationSSLPinningModePublicKey: { + id publicKey = (__bridge_transfer id)SecTrustCopyPublicKey(serverTrust); + + for (id allowedPublicKey in [self.class pinnedPublicKeys]) { + if ([allowedPublicKey isEqual:publicKey]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + + return; + } + } + + [[challenge sender] cancelAuthenticationChallenge:challenge]; + break; + } } } } From 3b1a09870165a04179e6e63b9c1f0fed1e145a27 Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Sat, 29 Dec 2012 13:06:52 +0100 Subject: [PATCH 0034/1434] Fixes memory leak. --- AFNetworking/AFURLConnectionOperation.m | 1 + 1 file changed, 1 insertion(+) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 0a590a2449..4633b8bded 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -214,6 +214,7 @@ + (NSArray *)pinnedPublicKeys { CFRelease(allowedTrust); CFRelease(allowedCertificate); + CFRelease(policy); } _pinnedPublicKeys = [[NSArray alloc] initWithArray:publicKeys]; From 80bb2ea52730e16f70456919ff9f587740662647 Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Sat, 29 Dec 2012 13:10:14 +0100 Subject: [PATCH 0035/1434] Gets rid of for loop to check if public key is present. --- AFNetworking/AFURLConnectionOperation.m | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 4633b8bded..c8d411cf31 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -546,16 +546,12 @@ - (void)connection:(NSURLConnection *)connection } case AFURLConnectionOperationSSLPinningModePublicKey: { id publicKey = (__bridge_transfer id)SecTrustCopyPublicKey(serverTrust); - for (id allowedPublicKey in [self.class pinnedPublicKeys]) { - if ([allowedPublicKey isEqual:publicKey]) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - - return; - } + if ([[self.class pinnedPublicKeys] containsObject:publicKey]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; } - - [[challenge sender] cancelAuthenticationChallenge:challenge]; break; } } From a610a89f8cb4f6eb08da31816d90afe9fbb18fbf Mon Sep 17 00:00:00 2001 From: Eric Florenzano Date: Thu, 3 Jan 2013 17:53:30 -0800 Subject: [PATCH 0036/1434] Added single quote to the chars to escape Ran into some issues with sending an unescaped apostrophe, but by adding it to the list of characters to escape, this problem is now fixed for me. --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 3fec759b34..9004e78788 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -81,7 +81,7 @@ } static NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { - static NSString * const kAFCharactersToBeEscaped = @":/?&=;+!@#$()~"; + static NSString * const kAFCharactersToBeEscaped = @":/?&=;+!@#$()~'"; static NSString * const kAFCharactersToLeaveUnescaped = @"[]."; return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, (__bridge CFStringRef)kAFCharactersToLeaveUnescaped, (__bridge CFStringRef)kAFCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)); From 1d243f779431660414e35cf7ed84faf93f77e600 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 4 Jan 2013 12:41:25 -0800 Subject: [PATCH 0037/1434] Adding credential property to AFURLConnectionOperation --- AFNetworking/AFURLConnectionOperation.h | 12 ++++++++++++ AFNetworking/AFURLConnectionOperation.m | 9 +++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 94c07e8957..0e0b805815 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -124,6 +124,18 @@ */ @property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; + +///-------------------------------- +/// @name Accessing URL Credentials +///-------------------------------- + +/** + The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. + + @discussion This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. + */ +@property (nonatomic, strong) NSURLCredential *credential; + ///------------------------ /// @name Accessing Streams ///------------------------ diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 0d27490b0a..0c540bf288 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -144,6 +144,7 @@ @implementation AFURLConnectionOperation @synthesize totalBytesRead = _totalBytesRead; @dynamic inputStream; @synthesize outputStream = _outputStream; +@synthesize credential = _credential; @synthesize userInfo = _userInfo; @synthesize backgroundTaskIdentifier = _backgroundTaskIdentifier; @synthesize uploadProgress = _uploadProgress; @@ -545,10 +546,10 @@ - (void)connection:(NSURLConnection *)connection } else { if ([challenge previousFailureCount] == 0) { NSURLCredential *credential = nil; - + NSString *username = (__bridge_transfer NSString *)CFURLCopyUserName((__bridge CFURLRef)[self.request URL]); NSString *password = (__bridge_transfer NSString *)CFURLCopyPassword((__bridge CFURLRef)[self.request URL]); - + if (username && password) { credential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceNone]; } else if (username) { @@ -556,6 +557,10 @@ - (void)connection:(NSURLConnection *)connection } else { credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]]; } + + if (!credential) { + credential = self.credential; + } if (credential) { [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; From c6137914fa9012e7beb11eed54cde70a8235f0cd Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 4 Jan 2013 12:52:14 -0800 Subject: [PATCH 0038/1434] Adding AFHTTPClient -setDefaultCredential: --- AFNetworking/AFHTTPClient.h | 18 ++++++++++++++++-- AFNetworking/AFHTTPClient.m | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 68c6de8f64..7e73762626 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -217,7 +217,8 @@ typedef enum { @param header The HTTP header to set a default value for @param value The value set as default for the specified header, or `nil */ -- (void)setDefaultHeader:(NSString *)header value:(NSString *)value; +- (void)setDefaultHeader:(NSString *)header + value:(NSString *)value; /** Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header. @@ -225,7 +226,8 @@ typedef enum { @param username The HTTP basic auth username @param password The HTTP basic auth password */ -- (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password; +- (void)setAuthorizationHeaderWithUsername:(NSString *)username + password:(NSString *)password; /** Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header. @@ -234,11 +236,23 @@ typedef enum { */ - (void)setAuthorizationHeaderWithToken:(NSString *)token; + /** Clears any existing value for the "Authorization" HTTP header. */ - (void)clearAuthorizationHeader; +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Set the default URL credential to be set for request operations. + + @param credential The URL credential + */ +- (void)setDefaultCredential:(NSURLCredential *)credential; + ///------------------------------- /// @name Creating Request Objects ///------------------------------- diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 3fec759b34..6ec823bcf5 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -179,6 +179,7 @@ @interface AFHTTPClient () @property (readwrite, nonatomic) NSURL *baseURL; @property (readwrite, nonatomic) NSMutableArray *registeredHTTPOperationClassNames; @property (readwrite, nonatomic) NSMutableDictionary *defaultHeaders; +@property (readwrite, nonatomic) NSURLCredential *defaultCredential; @property (readwrite, nonatomic) NSOperationQueue *operationQueue; #ifdef _SYSTEMCONFIGURATION_H @property (readwrite, nonatomic, assign) AFNetworkReachabilityRef networkReachability; @@ -517,6 +518,8 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR } [operation setCompletionBlockWithSuccess:success failure:failure]; + + operation.credential = self.defaultCredential; return operation; } From ecf6899d5fd1844ecffcb125349559adeb57306c Mon Sep 17 00:00:00 2001 From: Alex Burgel Date: Sat, 5 Jan 2013 15:10:47 -0500 Subject: [PATCH 0039/1434] Fix request stream exhaustion error by copying the original NSInputStream --- AFNetworking/AFHTTPClient.m | 58 ++++++++++++++++++++++--- AFNetworking/AFURLConnectionOperation.m | 13 ++++++ 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index f5b3fe010d..fe7ab7dbb5 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -740,7 +740,9 @@ - (id)copyWithZone:(NSZone *)zone { @interface AFHTTPBodyPart : NSObject @property (nonatomic, assign) NSStringEncoding stringEncoding; @property (nonatomic, strong) NSDictionary *headers; -@property (nonatomic, strong) NSInputStream *inputStream; +@property (nonatomic, strong) NSData *inputData; +@property (nonatomic, strong) NSURL *inputURL; +@property (nonatomic, readonly) NSInputStream *inputStream; @property (nonatomic, assign) unsigned long long bodyContentLength; @property (nonatomic, assign) BOOL hasInitialBoundary; @@ -821,8 +823,8 @@ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; bodyPart.stringEncoding = self.stringEncoding; bodyPart.headers = mutableHeaders; - bodyPart.inputStream = [NSInputStream inputStreamWithURL:fileURL]; - + bodyPart.inputURL = fileURL; + NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:nil]; bodyPart.bodyContentLength = [[fileAttributes objectForKey:NSFileSize] unsignedLongLongValue]; @@ -867,7 +869,7 @@ - (void)appendPartWithHeaders:(NSDictionary *)headers bodyPart.stringEncoding = self.stringEncoding; bodyPart.headers = headers; bodyPart.bodyContentLength = [body length]; - bodyPart.inputStream = [NSInputStream inputStreamWithData:body]; + bodyPart.inputData = body; [self.bodyStream appendHTTPBodyPart:bodyPart]; } @@ -898,7 +900,7 @@ - (NSMutableURLRequest *)requestByFinalizingMultipartFormData { #pragma mark - -@interface AFMultipartBodyStream () +@interface AFMultipartBodyStream () @property (nonatomic, assign) NSStreamStatus streamStatus; @property (nonatomic, strong) NSError *streamError; @@ -931,6 +933,20 @@ - (id)initWithStringEncoding:(NSStringEncoding)encoding { return self; } +-(id)copyWithZone:(NSZone *)zone { + AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; + + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) + { + AFHTTPBodyPart *bodyPartCopy = [bodyPart copy]; + [bodyStreamCopy appendHTTPBodyPart:bodyPartCopy]; + } + + [bodyStreamCopy setInitialAndFinalBoundaries]; + + return bodyStreamCopy; +} + - (void)setInitialAndFinalBoundaries { if ([self.HTTPBodyParts count] > 0) { for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { @@ -1051,8 +1067,9 @@ - (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags AFFinalBoundaryPhase = 4, } AFHTTPBodyPartReadPhase; -@interface AFHTTPBodyPart () { +@interface AFHTTPBodyPart () { AFHTTPBodyPartReadPhase _phase; + NSInputStream *_inputStream; unsigned long long _phaseReadOffset; } @@ -1063,7 +1080,8 @@ @implementation AFHTTPBodyPart @synthesize stringEncoding = _stringEncoding; @synthesize headers = _headers; @synthesize bodyContentLength = _bodyContentLength; -@synthesize inputStream = _inputStream; +@synthesize inputData = _inputData; +@synthesize inputURL = _inputURL; @synthesize hasInitialBoundary = _hasInitialBoundary; @synthesize hasFinalBoundary = _hasFinalBoundary; @@ -1078,6 +1096,18 @@ - (id)init { return self; } +- (id)copyWithZone:(NSZone *)zone { + AFHTTPBodyPart *bodyPartCopy = [[[self class] allocWithZone:zone] init]; + + bodyPartCopy.stringEncoding = self.stringEncoding; + bodyPartCopy.headers = self.headers; + bodyPartCopy.bodyContentLength = self.bodyContentLength; + bodyPartCopy.inputData = self.inputData; + bodyPartCopy.inputURL = self.inputURL; + + return bodyPartCopy; +} + - (void)dealloc { if (_inputStream) { [_inputStream close]; @@ -1085,6 +1115,20 @@ - (void)dealloc { } } +- (NSInputStream *)inputStream { + if (_inputStream) { + return _inputStream; + } + + if (self.inputData) { + _inputStream = [NSInputStream inputStreamWithData:self.inputData]; + } else if (self.inputURL) { + _inputStream = [NSInputStream inputStreamWithURL:self.inputURL]; + } + + return _inputStream; +} + - (NSString *)stringForHeaders { NSMutableString *headerString = [NSMutableString string]; for (NSString *field in [self.headers allKeys]) { diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 0c540bf288..24227a6338 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -657,6 +657,19 @@ - (NSCachedURLResponse *)connection:(NSURLConnection *)connection } } +- (NSInputStream *)connection:(NSURLConnection *)connection needNewBodyStream:(NSURLRequest *)request +{ + NSInputStream *newBodyStream = nil; + + NSInputStream *bodyStream = request.HTTPBodyStream; + if ([bodyStream conformsToProtocol:@protocol(NSCopying)]) + { + newBodyStream = [bodyStream copy]; + } + + return newBodyStream; +} + #pragma mark - NSCoding - (id)initWithCoder:(NSCoder *)aDecoder { From b7ec92850a686ad5f38dac6a57f828515a15f5d9 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sat, 5 Jan 2013 22:19:59 -0800 Subject: [PATCH 0040/1434] [Issue #715] Fixing warnings generated by earlier versions of Xcode (/cc Ignacio Rodrigo) Minor reformatting --- AFNetworking/AFHTTPClient.h | 4 ++-- AFNetworking/AFHTTPClient.m | 35 ++++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 7e73762626..72bc6c3b7f 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -109,7 +109,7 @@ typedef enum { /** The url used as the base for paths specified in methods such as `getPath:parameters:success:failure` */ -@property (readonly, nonatomic) NSURL *baseURL; +@property (readonly, nonatomic, strong) NSURL *baseURL; /** The string encoding used in constructing url requests. This is `NSUTF8StringEncoding` by default. @@ -126,7 +126,7 @@ typedef enum { /** The operation queue which manages operations enqueued by the HTTP client. */ -@property (readonly, nonatomic) NSOperationQueue *operationQueue; +@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue; /** The reachability status from the device to the current `baseURL` of the `AFHTTPClient`. diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index f5b3fe010d..91d8251513 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -176,11 +176,11 @@ - (NSMutableURLRequest *)requestByFinalizingMultipartFormData; #pragma mark - @interface AFHTTPClient () -@property (readwrite, nonatomic) NSURL *baseURL; -@property (readwrite, nonatomic) NSMutableArray *registeredHTTPOperationClassNames; -@property (readwrite, nonatomic) NSMutableDictionary *defaultHeaders; -@property (readwrite, nonatomic) NSURLCredential *defaultCredential; -@property (readwrite, nonatomic) NSOperationQueue *operationQueue; +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@property (readwrite, nonatomic, strong) NSMutableArray *registeredHTTPOperationClassNames; +@property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders; +@property (readwrite, nonatomic, strong) NSURLCredential *defaultCredential; +@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue; #ifdef _SYSTEMCONFIGURATION_H @property (readwrite, nonatomic, assign) AFNetworkReachabilityRef networkReachability; @property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; @@ -199,6 +199,7 @@ @implementation AFHTTPClient @synthesize parameterEncoding = _parameterEncoding; @synthesize registeredHTTPOperationClassNames = _registeredHTTPOperationClassNames; @synthesize defaultHeaders = _defaultHeaders; +@synthesize defaultCredential = _defaultCredential; @synthesize operationQueue = _operationQueue; #ifdef _SYSTEMCONFIGURATION_H @synthesize networkReachability = _networkReachability; @@ -711,7 +712,7 @@ - (id)copyWithZone:(NSZone *)zone { static NSString * const kAFMultipartFormCRLF = @"\r\n"; -static NSInteger const kAFStreamToStreamBufferSize = 1024*1024; //1 meg default +static NSInteger const kAFStreamToStreamBufferSize = 1024 * 1024; //1 meg default static inline NSString * AFMultipartFormInitialBoundary() { return [NSString stringWithFormat:@"--%@%@", kAFMultipartFormBoundary, kAFMultipartFormCRLF]; @@ -749,7 +750,8 @@ @interface AFHTTPBodyPart : NSObject @property (nonatomic, readonly, getter = hasBytesAvailable) BOOL bytesAvailable; @property (nonatomic, readonly) unsigned long long contentLength; -- (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length; +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length; @end @interface AFMultipartBodyStream : NSInputStream @@ -953,7 +955,9 @@ - (BOOL)isEmpty { #pragma mark - NSInputStream -- (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ if ([self streamStatus] == NSStreamStatusClosed) { return 0; } @@ -974,7 +978,9 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { return bytesRead; } -- (BOOL)getBuffer:(__unused uint8_t **)buffer length:(__unused NSUInteger *)len { +- (BOOL)getBuffer:(__unused uint8_t **)buffer + length:(__unused NSUInteger *)len +{ return NO; } @@ -1003,7 +1009,9 @@ - (id)propertyForKey:(__unused NSString *)key { return nil; } -- (BOOL)setProperty:(__unused id)property forKey:(__unused NSString *)key { +- (BOOL)setProperty:(__unused id)property + forKey:(__unused NSString *)key +{ return NO; } @@ -1057,6 +1065,9 @@ @interface AFHTTPBodyPart () { } - (BOOL)transitionToNextPhase; +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length; @end @implementation AFHTTPBodyPart @@ -1132,7 +1143,9 @@ - (BOOL)hasBytesAvailable { } } -- (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ NSInteger bytesRead = 0; if (_phase == AFEncapsulationBoundaryPhase) { From 23d3bd5af4d9d895c5d3349550db98d05cc3ba37 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sat, 5 Jan 2013 23:40:24 -0800 Subject: [PATCH 0041/1434] Minor reformatting --- AFNetworking/AFHTTPClient.m | 79 ++++++++++++------------- AFNetworking/AFURLConnectionOperation.h | 1 + AFNetworking/AFURLConnectionOperation.m | 15 ++--- 3 files changed, 45 insertions(+), 50 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index e8bb6cd55c..903ee9b6cb 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -741,10 +741,9 @@ - (id)copyWithZone:(NSZone *)zone { @interface AFHTTPBodyPart : NSObject @property (nonatomic, assign) NSStringEncoding stringEncoding; @property (nonatomic, strong) NSDictionary *headers; -@property (nonatomic, strong) NSData *inputData; -@property (nonatomic, strong) NSURL *inputURL; -@property (nonatomic, readonly) NSInputStream *inputStream; +@property (nonatomic, strong) id body; @property (nonatomic, assign) unsigned long long bodyContentLength; +@property (nonatomic, readonly) NSInputStream *inputStream; @property (nonatomic, assign) BOOL hasInitialBoundary; @property (nonatomic, assign) BOOL hasFinalBoundary; @@ -825,7 +824,7 @@ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; bodyPart.stringEncoding = self.stringEncoding; bodyPart.headers = mutableHeaders; - bodyPart.inputURL = fileURL; + bodyPart.body = fileURL; NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:nil]; bodyPart.bodyContentLength = [[fileAttributes objectForKey:NSFileSize] unsignedLongLongValue]; @@ -871,7 +870,7 @@ - (void)appendPartWithHeaders:(NSDictionary *)headers bodyPart.stringEncoding = self.stringEncoding; bodyPart.headers = headers; bodyPart.bodyContentLength = [body length]; - bodyPart.inputData = body; + bodyPart.body = body; [self.bodyStream appendHTTPBodyPart:bodyPart]; } @@ -935,20 +934,6 @@ - (id)initWithStringEncoding:(NSStringEncoding)encoding { return self; } --(id)copyWithZone:(NSZone *)zone { - AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; - - for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) - { - AFHTTPBodyPart *bodyPartCopy = [bodyPart copy]; - [bodyStreamCopy appendHTTPBodyPart:bodyPartCopy]; - } - - [bodyStreamCopy setInitialAndFinalBoundaries]; - - return bodyStreamCopy; -} - - (void)setInitialAndFinalBoundaries { if ([self.HTTPBodyParts count] > 0) { for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { @@ -1064,6 +1049,20 @@ - (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags return NO; } +#pragma mark - NSCopying + +-(id)copyWithZone:(NSZone *)zone { + AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; + + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]]; + } + + [bodyStreamCopy setInitialAndFinalBoundaries]; + + return bodyStreamCopy; +} + @end #pragma mark - @@ -1090,9 +1089,8 @@ - (NSInteger)readData:(NSData *)data @implementation AFHTTPBodyPart @synthesize stringEncoding = _stringEncoding; @synthesize headers = _headers; +@synthesize body = _body; @synthesize bodyContentLength = _bodyContentLength; -@synthesize inputData = _inputData; -@synthesize inputURL = _inputURL; @synthesize hasInitialBoundary = _hasInitialBoundary; @synthesize hasFinalBoundary = _hasFinalBoundary; @@ -1107,18 +1105,6 @@ - (id)init { return self; } -- (id)copyWithZone:(NSZone *)zone { - AFHTTPBodyPart *bodyPartCopy = [[[self class] allocWithZone:zone] init]; - - bodyPartCopy.stringEncoding = self.stringEncoding; - bodyPartCopy.headers = self.headers; - bodyPartCopy.bodyContentLength = self.bodyContentLength; - bodyPartCopy.inputData = self.inputData; - bodyPartCopy.inputURL = self.inputURL; - - return bodyPartCopy; -} - - (void)dealloc { if (_inputStream) { [_inputStream close]; @@ -1127,14 +1113,12 @@ - (void)dealloc { } - (NSInputStream *)inputStream { - if (_inputStream) { - return _inputStream; - } - - if (self.inputData) { - _inputStream = [NSInputStream inputStreamWithData:self.inputData]; - } else if (self.inputURL) { - _inputStream = [NSInputStream inputStreamWithURL:self.inputURL]; + if (!_inputStream) { + if ([self.body isKindOfClass:[NSData class]]) { + _inputStream = [NSInputStream inputStreamWithData:self.body]; + } else if ([self.body isKindOfClass:[NSURL class]]) { + _inputStream = [NSInputStream inputStreamWithURL:self.body]; + } } return _inputStream; @@ -1265,4 +1249,17 @@ - (BOOL)transitionToNextPhase { return YES; } +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init]; + + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = self.headers; + bodyPart.bodyContentLength = self.bodyContentLength; + bodyPart.body = self.body; + + return bodyPart; +} + @end diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 0e0b805815..b8b8eee54c 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -45,6 +45,7 @@ - `connection:willCacheResponse:` - `connection:canAuthenticateAgainstProtectionSpace:` - `connection:didReceiveAuthenticationChallenge:` + - `connection:needNewBodyStream:` If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 24227a6338..d95be67e2e 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -657,17 +657,14 @@ - (NSCachedURLResponse *)connection:(NSURLConnection *)connection } } -- (NSInputStream *)connection:(NSURLConnection *)connection needNewBodyStream:(NSURLRequest *)request -{ - NSInputStream *newBodyStream = nil; - - NSInputStream *bodyStream = request.HTTPBodyStream; - if ([bodyStream conformsToProtocol:@protocol(NSCopying)]) - { - newBodyStream = [bodyStream copy]; +- (NSInputStream *)connection:(NSURLConnection *)connection + needNewBodyStream:(NSURLRequest *)request +{ + if ([request.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { + return [request.HTTPBodyStream copy]; } - return newBodyStream; + return nil; } #pragma mark - NSCoding From b66c21b0f298d2e8fd9abaa34e7cedaf319f3902 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sat, 5 Jan 2013 23:48:48 -0800 Subject: [PATCH 0042/1434] Re-ordering NSURLConnectionDelegate method implementations --- AFNetworking/AFURLConnectionOperation.m | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index d95be67e2e..2dfc525bcb 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -573,6 +573,16 @@ - (void)connection:(NSURLConnection *)connection } } +- (NSInputStream *)connection:(NSURLConnection *)connection + needNewBodyStream:(NSURLRequest *)request +{ + if ([request.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { + return [request.HTTPBodyStream copy]; + } + + return nil; +} + - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse @@ -657,16 +667,6 @@ - (NSCachedURLResponse *)connection:(NSURLConnection *)connection } } -- (NSInputStream *)connection:(NSURLConnection *)connection - needNewBodyStream:(NSURLRequest *)request -{ - if ([request.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { - return [request.HTTPBodyStream copy]; - } - - return nil; -} - #pragma mark - NSCoding - (id)initWithCoder:(NSCoder *)aDecoder { From 1e7c45c191bb0f157c6bcba6e59b4079ee698b79 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 6 Jan 2013 20:39:59 -0800 Subject: [PATCH 0043/1434] Marking connection parameter in connection:needNewBodyStream: as __unused --- AFNetworking/AFURLConnectionOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 2dfc525bcb..06f9ce4637 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -573,7 +573,7 @@ - (void)connection:(NSURLConnection *)connection } } -- (NSInputStream *)connection:(NSURLConnection *)connection +- (NSInputStream *)connection:(NSURLConnection __unused *)connection needNewBodyStream:(NSURLRequest *)request { if ([request.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { From 9aeb38649b21aba03d2e05aa4f4a25fa73d1815d Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 6 Jan 2013 20:44:48 -0800 Subject: [PATCH 0044/1434] [Issue #719] Adding shouldUseCredentialStorage property to AFURLConnectionOperation /thanks Xihe Yu --- AFNetworking/AFURLConnectionOperation.h | 13 ++++++++++--- AFNetworking/AFURLConnectionOperation.m | 7 +++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index b8b8eee54c..901cb94cdf 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -126,9 +126,16 @@ @property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; -///-------------------------------- -/// @name Accessing URL Credentials -///-------------------------------- +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. + + @discussion This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; /** The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 06f9ce4637..17c98c9510 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -145,6 +145,7 @@ @implementation AFURLConnectionOperation @dynamic inputStream; @synthesize outputStream = _outputStream; @synthesize credential = _credential; +@synthesize shouldUseCredentialStorage = _shouldUseCredentialStorage; @synthesize userInfo = _userInfo; @synthesize backgroundTaskIdentifier = _backgroundTaskIdentifier; @synthesize uploadProgress = _uploadProgress; @@ -205,6 +206,8 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest { self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes]; self.request = urlRequest; + + self.shouldUseCredentialStorage = YES; self.outputStream = [NSOutputStream outputStreamToMemory]; @@ -573,6 +576,10 @@ - (void)connection:(NSURLConnection *)connection } } +- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection { + return self.shouldUseCredentialStorage; +} + - (NSInputStream *)connection:(NSURLConnection __unused *)connection needNewBodyStream:(NSURLRequest *)request { From 965b3670a7405c638622d96d0c1c9f76d9dcdfa3 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 6 Jan 2013 20:46:08 -0800 Subject: [PATCH 0045/1434] Updating list of implemented NSURLConnectionDelegate method --- AFNetworking/AFURLConnectionOperation.h | 1 + 1 file changed, 1 insertion(+) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 901cb94cdf..2afec5ee05 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -45,6 +45,7 @@ - `connection:willCacheResponse:` - `connection:canAuthenticateAgainstProtectionSpace:` - `connection:didReceiveAuthenticationChallenge:` + - `connectionShouldUseCredentialStorage:` - `connection:needNewBodyStream:` If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. From 9173264a3f99d39b584b40c3c7483318d8cf95da Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 16 Jan 2013 07:42:36 -0800 Subject: [PATCH 0046/1434] Adding AFNetworking architecture diagram --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 747c78dfcb..fbf24ea2d0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -AFNetworking +AFNetworking AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of [NSURLConnection](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html), [NSOperation](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperation_class/Reference/Reference.html), and other familiar Foundation technologies. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. For example, here's how easy it is to get JSON from a URL: @@ -25,6 +25,10 @@ Choose AFNetworking for your next project, or migrate over your existing project ## Overview +

+ AFNetworking Architecture Diagram +

+ AFNetworking is architected to be as small and modular as possible, in order to make it simple to use and extend. @@ -177,3 +181,4 @@ Follow AFNetworking on Twitter ([@AFNetworking](https://twitter.com/AFNetworking ## License AFNetworking is available under the MIT license. See the LICENSE file for more info. + From 46bc122debe848d3523a377b8b61de760fcb5d6f Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 16 Jan 2013 07:43:15 -0800 Subject: [PATCH 0047/1434] Fixing link to diagram in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fbf24ea2d0..e6888108bf 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Choose AFNetworking for your next project, or migrate over your existing project ## Overview

- AFNetworking Architecture Diagram + AFNetworking Architecture Diagram

AFNetworking is architected to be as small and modular as possible, in order to make it simple to use and extend. From 2b8be998cedf096c1a6c1234211494a672772c12 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 16 Jan 2013 07:46:10 -0800 Subject: [PATCH 0048/1434] Fixing center alignment --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6888108bf..2397948313 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Choose AFNetworking for your next project, or migrate over your existing project ## Overview -

+

AFNetworking Architecture Diagram

From c79a2c87a8b927f0e6648c53b35c176af5102f05 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 16 Jan 2013 07:54:27 -0800 Subject: [PATCH 0049/1434] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2397948313..01e75a1818 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -AFNetworking +

+ AFNetworking +

AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of [NSURLConnection](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html), [NSOperation](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperation_class/Reference/Reference.html), and other familiar Foundation technologies. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. For example, here's how easy it is to get JSON from a URL: From 74346addea29b0ed1a35dc5657858660df565e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Fri, 18 Jan 2013 15:06:14 +0100 Subject: [PATCH 0050/1434] Use NSURL methods instead of CFURL functions * Replace CFURLCopyUserName with -[NSURL user] * Replace CFURLCopyPassword with -[NSURL password] --- AFNetworking/AFURLConnectionOperation.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 17c98c9510..fa4b488cf9 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -550,8 +550,8 @@ - (void)connection:(NSURLConnection *)connection if ([challenge previousFailureCount] == 0) { NSURLCredential *credential = nil; - NSString *username = (__bridge_transfer NSString *)CFURLCopyUserName((__bridge CFURLRef)[self.request URL]); - NSString *password = (__bridge_transfer NSString *)CFURLCopyPassword((__bridge CFURLRef)[self.request URL]); + NSString *username = [[self.request URL] user]; + NSString *password = [[self.request URL] password]; if (username && password) { credential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceNone]; From 7abc97881e66b7846d1262877efa523ccdb740eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Fri, 18 Jan 2013 15:08:29 +0100 Subject: [PATCH 0051/1434] Rename the `username` variable to `user` --- AFNetworking/AFURLConnectionOperation.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index fa4b488cf9..8c4edf2a16 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -550,13 +550,13 @@ - (void)connection:(NSURLConnection *)connection if ([challenge previousFailureCount] == 0) { NSURLCredential *credential = nil; - NSString *username = [[self.request URL] user]; + NSString *user = [[self.request URL] user]; NSString *password = [[self.request URL] password]; - if (username && password) { - credential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceNone]; - } else if (username) { - credential = [[[NSURLCredentialStorage sharedCredentialStorage] credentialsForProtectionSpace:[challenge protectionSpace]] objectForKey:username]; + if (user && password) { + credential = [NSURLCredential credentialWithUser:user password:password persistence:NSURLCredentialPersistenceNone]; + } else if (user) { + credential = [[[NSURLCredentialStorage sharedCredentialStorage] credentialsForProtectionSpace:[challenge protectionSpace]] objectForKey:user]; } else { credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]]; } From b337828e96030b0582ae56f85617e7c42fbe555f Mon Sep 17 00:00:00 2001 From: Peyman Date: Mon, 7 Jan 2013 16:03:33 -0800 Subject: [PATCH 0052/1434] Fix race condition in UIImageView+AFNetworking --- AFNetworking/UIImageView+AFNetworking.m | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/AFNetworking/UIImageView+AFNetworking.m b/AFNetworking/UIImageView+AFNetworking.m index f399c0e620..91919cade1 100644 --- a/AFNetworking/UIImageView+AFNetworking.m +++ b/AFNetworking/UIImageView+AFNetworking.m @@ -119,8 +119,10 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest } else { self.image = responseObject; } - - self.af_imageRequestOperation = nil; + + if (self.af_imageRequestOperation == operation) { + self.af_imageRequestOperation = nil; + } } [[[self class] af_sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; @@ -129,13 +131,15 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest if (failure) { failure(operation.request, operation.response, error); } - - self.af_imageRequestOperation = nil; + + if (self.af_imageRequestOperation == operation) { + self.af_imageRequestOperation = nil; + } } }]; - + self.af_imageRequestOperation = requestOperation; - + [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation]; } } From 1368e618a69c5c9b7f0f631e4faa6c42f44b879c Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 24 Jan 2013 17:00:27 -0500 Subject: [PATCH 0053/1434] [Issue #751] Removing NSURLConnectionDataDelegate from AFURLConnectionOperation's declared protocols --- AFNetworking/AFURLConnectionOperation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 2afec5ee05..27d9969764 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -75,7 +75,7 @@ - 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 would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. */ -@interface AFURLConnectionOperation : NSOperation +@interface AFURLConnectionOperation : NSOperation ///------------------------------- /// @name Accessing Run Loop Modes From 6a11c82120ab7ce54c5db6f8f6965d994ae5eff7 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 24 Jan 2013 17:01:25 -0500 Subject: [PATCH 0054/1434] Suppressing warning caused by AFHTTPBodyPart -hasBytesAvailable not having default condition in switch statement --- AFNetworking/AFHTTPClient.m | 1 + 1 file changed, 1 insertion(+) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 903ee9b6cb..d9a066b424 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1167,6 +1167,7 @@ - (BOOL)hasBytesAvailable { case NSStreamStatusAtEnd: case NSStreamStatusClosed: case NSStreamStatusError: + default: return NO; } } From cd8cee4ac81f3e7e710bbb2c01dfb9a415ba9efa Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 25 Jan 2013 08:56:43 -0500 Subject: [PATCH 0055/1434] Enqueuing operation in upload example rather than calling -start directly --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 01e75a1818..e60615f5ff 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequ [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite); }]; -[operation start]; +[httpClient enqueueHTTPRequestOperation:operation]; ``` ### Streaming Request From d9da9e5c1a0d79419b89cd53670fced30d550d74 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sat, 26 Jan 2013 10:31:16 -0500 Subject: [PATCH 0056/1434] Whitespace formatting --- AFNetworking/UIImageView+AFNetworking.m | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/AFNetworking/UIImageView+AFNetworking.m b/AFNetworking/UIImageView+AFNetworking.m index 91919cade1..2e8b9c1e2d 100644 --- a/AFNetworking/UIImageView+AFNetworking.m +++ b/AFNetworking/UIImageView+AFNetworking.m @@ -1,17 +1,17 @@ // UIImageView+AFNetworking.m // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -63,7 +63,7 @@ + (NSOperationQueue *)af_sharedImageRequestOperationQueue { _af_imageRequestOperationQueue = [[NSOperationQueue alloc] init]; [_af_imageRequestOperationQueue setMaxConcurrentOperationCount:NSOperationQueueDefaultMaxConcurrentOperationCount]; }); - + return _af_imageRequestOperationQueue; } @@ -73,7 +73,7 @@ + (AFImageCache *)af_sharedImageCache { dispatch_once(&oncePredicate, ^{ _af_imageCache = [[AFImageCache alloc] init]; }); - + return _af_imageCache; } @@ -83,34 +83,34 @@ - (void)setImageWithURL:(NSURL *)url { [self setImageWithURL:url placeholderImage:nil]; } -- (void)setImageWithURL:(NSURL *)url +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholderImage { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPShouldHandleCookies:NO]; [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; - + [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; } -- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest - placeholderImage:(UIImage *)placeholderImage +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(UIImage *)placeholderImage success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure { [self cancelImageRequestOperation]; - + UIImage *cachedImage = [[[self class] af_sharedImageCache] cachedImageForRequest:urlRequest]; if (cachedImage) { self.image = cachedImage; self.af_imageRequestOperation = nil; - + if (success) { success(nil, nil, cachedImage); } } else { self.image = placeholderImage; - + AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) { @@ -121,7 +121,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest } if (self.af_imageRequestOperation == operation) { - self.af_imageRequestOperation = nil; + self.af_imageRequestOperation = nil; } } @@ -133,7 +133,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest } if (self.af_imageRequestOperation == operation) { - self.af_imageRequestOperation = nil; + self.af_imageRequestOperation = nil; } } }]; @@ -167,7 +167,7 @@ - (UIImage *)cachedImageForRequest:(NSURLRequest *)request { default: break; } - + return [self objectForKey:AFImageCacheKeyFromURLRequest(request)]; } From 6e69da9feba5a5915215d8e94f031a23e4205fae Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sat, 26 Jan 2013 10:47:11 -0500 Subject: [PATCH 0057/1434] Using early return in AFURLConnectionOperation -setState: to avoid posting notifications in lock --- AFNetworking/AFURLConnectionOperation.m | 48 +++++++++++++------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 8c4edf2a16..cd4b93d42b 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -325,31 +325,33 @@ - (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection } - (void)setState:(AFOperationState)state { - [self.lock lock]; - if (AFStateTransitionIsValid(self.state, state, [self isCancelled])) { - NSString *oldStateKey = AFKeyPathFromOperationState(self.state); - NSString *newStateKey = AFKeyPathFromOperationState(state); - - [self willChangeValueForKey:newStateKey]; - [self willChangeValueForKey:oldStateKey]; - _state = state; - [self didChangeValueForKey:oldStateKey]; - [self didChangeValueForKey:newStateKey]; - - dispatch_async(dispatch_get_main_queue(), ^{ - switch (state) { - case AFOperationExecutingState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; - break; - case AFOperationFinishedState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; - break; - default: - break; - } - }); + if (!AFStateTransitionIsValid(self.state, state, [self isCancelled])) { + return; } + + [self.lock lock]; + NSString *oldStateKey = AFKeyPathFromOperationState(self.state); + NSString *newStateKey = AFKeyPathFromOperationState(state); + + [self willChangeValueForKey:newStateKey]; + [self willChangeValueForKey:oldStateKey]; + _state = state; + [self didChangeValueForKey:oldStateKey]; + [self didChangeValueForKey:newStateKey]; [self.lock unlock]; + + dispatch_async(dispatch_get_main_queue(), ^{ + switch (state) { + case AFOperationExecutingState: + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; + break; + case AFOperationFinishedState: + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + break; + default: + break; + } + }); } - (NSString *)responseString { From 317dd753d9d97f74adefbd1a420ef45af72e2d75 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sat, 26 Jan 2013 11:32:13 -0500 Subject: [PATCH 0058/1434] [Issue #737] Updating default Accept-Language header value in AFHTTPClient --- AFNetworking/AFHTTPClient.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index d9a066b424..f78780576a 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -234,8 +234,13 @@ - (id)initWithBaseURL:(NSURL *)url { self.defaultHeaders = [NSMutableDictionary dictionary]; // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 - NSString *preferredLanguageCodes = [[NSLocale preferredLanguages] componentsJoinedByString:@", "]; - [self setDefaultHeader:@"Accept-Language" value:[NSString stringWithFormat:@"%@, en-us;q=0.8", preferredLanguageCodes]]; + NSMutableArray *acceptLanguagesComponents = [NSMutableArray array]; + [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + float q = 1.0f - (idx * 0.1f); + [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]]; + *stop = q <= 0.0f; + }]; + [self setDefaultHeader:@"Accept-Language" value:[acceptLanguagesComponents componentsJoinedByString:@", "]]; #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 From 83da1edd1322ece4a748acc102f3248c529d7262 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 27 Jan 2013 12:15:07 -0500 Subject: [PATCH 0059/1434] Whitespace formatting by Xcode re-indentation --- AFNetworking/AFHTTPClient.h | 262 +++++++++--------- AFNetworking/AFHTTPClient.m | 226 +++++++-------- AFNetworking/AFHTTPRequestOperation.h | 24 +- AFNetworking/AFHTTPRequestOperation.m | 50 ++-- AFNetworking/AFImageRequestOperation.h | 28 +- AFNetworking/AFImageRequestOperation.m | 38 +-- AFNetworking/AFJSONRequestOperation.h | 4 +- AFNetworking/AFJSONRequestOperation.m | 20 +- .../AFNetworkActivityIndicatorManager.h | 24 +- .../AFNetworkActivityIndicatorManager.m | 16 +- AFNetworking/AFPropertyListRequestOperation.h | 16 +- AFNetworking/AFPropertyListRequestOperation.m | 22 +- AFNetworking/AFURLConnectionOperation.h | 108 ++++---- AFNetworking/AFURLConnectionOperation.m | 128 ++++----- AFNetworking/AFXMLRequestOperation.h | 24 +- AFNetworking/AFXMLRequestOperation.m | 26 +- AFNetworking/UIImageView+AFNetworking.h | 28 +- 17 files changed, 522 insertions(+), 522 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 72bc6c3b7f..9c64687a07 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -1,17 +1,17 @@ // AFHTTPClient.h // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -26,35 +26,35 @@ /** `AFHTTPClient` captures the common patterns of communicating with an web application over HTTP. It encapsulates information like base URL, authorization credentials, and HTTP headers, and uses them to construct and manage the execution of HTTP request operations. - + ## Automatic Content Parsing - + Instances of `AFHTTPClient` may specify which types of requests it expects and should handle by registering HTTP operation classes for automatic parsing. Registered classes will determine whether they can handle a particular request, and then construct a request operation accordingly in `enqueueHTTPRequestOperationWithRequest:success:failure`. - + ## Subclassing Notes - + In most cases, one should create an `AFHTTPClient` subclass for each website or web application that your application communicates with. It is often useful, also, to define a class method that returns a singleton shared HTTP client in each subclass, that persists authentication credentials and other configuration across the entire application. - + ## Methods to Override - + To change the behavior of all url request construction for an `AFHTTPClient` subclass, override `requestWithMethod:path:parameters`. - + To change the behavior of all request operation construction for an `AFHTTPClient` subclass, override `HTTPRequestOperationWithRequest:success:failure`. - + ## Default Headers - + By default, `AFHTTPClient` sets the following HTTP headers: - + - `Accept-Language: (comma-delimited preferred languages), en-us;q=0.8` - `User-Agent: (generated user agent)` - + You can override these HTTP headers or define new ones using `setDefaultHeader:value:`. - + ## URL Construction Using Relative Paths - + Both `-requestWithMethod:path:parameters:` and `-multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:` construct URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`. Below are a few examples of how `baseURL` and relative paths interact: - - NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo @@ -65,9 +65,9 @@ Also important to note is that a trailing slash will be added to any `baseURL` without one, which would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. ## NSCoding / NSCopying Conformance - + `AFHTTPClient` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however: - + - Archives and copies of HTTP clients will be initialized with an empty operation queue. - NSCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set. */ @@ -80,15 +80,15 @@ typedef enum { AFNetworkReachabilityStatusReachableViaWiFi = 2, } AFNetworkReachabilityStatus; #else - #warning SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available. +#warning SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available. #endif #ifndef __UTTYPE__ - #if __IPHONE_OS_VERSION_MIN_REQUIRED - #warning MobileCoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available. - #else - #warning CoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available. - #endif +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#warning MobileCoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available. +#else +#warning CoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available. +#endif #endif typedef enum { @@ -118,7 +118,7 @@ typedef enum { /** The `AFHTTPClientParameterEncoding` value corresponding to how parameters are encoded into a request body. This is `AFFormURLParameterEncoding` by default. - + @warning Some nested parameter structures, such as a keyed array of hashes containing inconsistent keys (i.e. `@{@"": @[@{@"a" : @(1)}, @{@"b" : @(2)}]}`), cannot be unambiguously represented in query strings. It is strongly recommended that an unambiguous encoding, such as `AFJSONParameterEncoding`, is used when posting complicated or nondeterministic parameter structures. */ @property (nonatomic, assign) AFHTTPClientParameterEncoding parameterEncoding; @@ -131,7 +131,7 @@ typedef enum { /** The reachability status from the device to the current `baseURL` of the `AFHTTPClient`. - @warning This property requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). + @warning This property requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). */ #ifdef _SYSTEMCONFIGURATION_H @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; @@ -143,20 +143,20 @@ typedef enum { /** Creates and initializes an `AFHTTPClient` object with the specified base URL. - + @param url The base URL for the HTTP client. This argument must not be `nil`. - + @return The newly-initialized HTTP client */ + (instancetype)clientWithBaseURL:(NSURL *)url; /** Initializes an `AFHTTPClient` object with the specified base URL. - + @param url The base URL for the HTTP client. This argument must not be `nil`. - + @discussion This is the designated initializer. - + @return The newly-initialized HTTP client */ - (id)initWithBaseURL:(NSURL *)url; @@ -167,9 +167,9 @@ typedef enum { /** Sets a callback to be executed when the network availability of the `baseURL` host changes. - + @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`. - + @warning This method requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). */ #ifdef _SYSTEMCONFIGURATION_H @@ -182,11 +182,11 @@ typedef enum { /** Attempts to register a subclass of `AFHTTPRequestOperation`, adding it to a chain to automatically generate request operations from a URL request. - + @param operationClass The subclass of `AFHTTPRequestOperation` to register - + @return `YES` if the registration is successful, `NO` otherwise. The only failure condition is if `operationClass` is not a subclass of `AFHTTPRequestOperation`. - + @discussion When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list. */ - (BOOL)registerHTTPOperationClass:(Class)operationClass; @@ -194,7 +194,7 @@ typedef enum { /** Unregisters the specified subclass of `AFHTTPRequestOperation` from the chain of classes consulted when `-requestWithMethod:path:parameters` is called. - @param operationClass The subclass of `AFHTTPRequestOperation` to register + @param operationClass The subclass of `AFHTTPRequestOperation` to register */ - (void)unregisterHTTPOperationClass:(Class)operationClass; @@ -204,16 +204,16 @@ typedef enum { /** Returns the value for the HTTP headers set in request objects created by the HTTP client. - + @param header The HTTP header to return the default value for - + @return The default value for the HTTP header, or `nil` if unspecified */ - (NSString *)defaultValueForHeader:(NSString *)header; /** Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header. - + @param header The HTTP header to set a default value for @param value The value set as default for the specified header, or `nil */ @@ -222,7 +222,7 @@ typedef enum { /** Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header. - + @param username The HTTP basic auth username @param password The HTTP basic auth password */ @@ -231,7 +231,7 @@ typedef enum { /** Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header. - + @param token The authentication token */ - (void)setAuthorizationHeaderWithToken:(NSString *)token; @@ -248,7 +248,7 @@ typedef enum { /** Set the default URL credential to be set for request operations. - + @param credential The URL credential */ - (void)setDefaultCredential:(NSURLCredential *)credential; @@ -259,29 +259,29 @@ typedef enum { /** Creates an `NSMutableURLRequest` object with the specified HTTP method and path. - + If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body. - + @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`. @param path The path to be appended to the HTTP client's base URL and used as the request URL. If `nil`, no path will be appended to the base URL. @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body. - - @return An `NSMutableURLRequest` object + + @return An `NSMutableURLRequest` object */ -- (NSMutableURLRequest *)requestWithMethod:(NSString *)method - path:(NSString *)path +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + path:(NSString *)path parameters:(NSDictionary *)parameters; /** Creates an `NSMutableURLRequest` object with the specified HTTP method and path, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2 - + @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`. @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and set in the request HTTP body. @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. This can be used to upload files, encode HTTP body as JSON or XML, or specify multiple values for the same parameter, as one might for array values. - + @discussion Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. - + @return An `NSMutableURLRequest` object */ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method @@ -295,9 +295,9 @@ typedef enum { /** Creates an `AFHTTPRequestOperation`. - + In order to determine what kind of operation is created, each registered subclass conforming to the `AFHTTPClient` protocol is consulted (in reverse order of when they were specified) to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to generate an operation using `HTTPRequestOperationWithRequest:success:failure:`. - + @param urlRequest The request object to be loaded asynchronously during execution of the operation. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. @@ -312,17 +312,17 @@ typedef enum { /** Enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue. - + @param operation The HTTP request operation to be enqueued. */ - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation; /** Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path. - - @param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled. + + @param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled. @param path The path appended to the HTTP client base URL to match against the cancelled requests. If `nil`, no path will be appended to the base URL. - + @discussion This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property. */ - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path; @@ -333,26 +333,26 @@ typedef enum { /** Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue for each specified request object into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes. - + @param urlRequests The `NSURLRequest` objects used to create and enqueue operations. @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations. - @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations. - + @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations. + @discussion Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters. */ - (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests - progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock completionBlock:(void (^)(NSArray *operations))completionBlock; /** Enqueues the specified request operations into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes. - + @param operations The request operations used to be batched and enqueued. @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations. - @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations. + @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations. */ -- (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations - progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock +- (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock completionBlock:(void (^)(NSArray *operations))completionBlock; ///--------------------------- @@ -361,12 +361,12 @@ typedef enum { /** Creates an `AFHTTPRequestOperation` with a `GET` request, and enqueues it to the HTTP client's operation queue. - + @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and appended as the query string for the request URL. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. - + @see -HTTPRequestOperationWithRequest:success:failure: */ - (void)getPath:(NSString *)path @@ -376,61 +376,61 @@ typedef enum { /** Creates an `AFHTTPRequestOperation` with a `POST` request, and enqueues it to the HTTP client's operation queue. - + @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and set in the request HTTP body. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. - + @see -HTTPRequestOperationWithRequest:success:failure: */ -- (void)postPath:(NSString *)path - parameters:(NSDictionary *)parameters +- (void)postPath:(NSString *)path + parameters:(NSDictionary *)parameters success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; /** Creates an `AFHTTPRequestOperation` with a `PUT` request, and enqueues it to the HTTP client's operation queue. - + @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and set in the request HTTP body. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. - + @see -HTTPRequestOperationWithRequest:success:failure: */ -- (void)putPath:(NSString *)path - parameters:(NSDictionary *)parameters +- (void)putPath:(NSString *)path + parameters:(NSDictionary *)parameters success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; /** Creates an `AFHTTPRequestOperation` with a `DELETE` request, and enqueues it to the HTTP client's operation queue. - + @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and appended as the query string for the request URL. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. - + @see -HTTPRequestOperationWithRequest:success:failure: */ -- (void)deletePath:(NSString *)path - parameters:(NSDictionary *)parameters +- (void)deletePath:(NSString *)path + parameters:(NSDictionary *)parameters success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; /** Creates an `AFHTTPRequestOperation` with a `PATCH` request, and enqueues it to the HTTP client's operation queue. - + @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and set in the request HTTP body. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. - + @see -HTTPRequestOperationWithRequest:success:failure: */ - (void)patchPath:(NSString *)path - parameters:(NSDictionary *)parameters + parameters:(NSDictionary *)parameters success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; @end @@ -441,54 +441,54 @@ typedef enum { /** ### Network Reachability - - The following constants are provided by `AFHTTPClient` as possible network reachability statuses. - + + The following constants are provided by `AFHTTPClient` as possible network reachability statuses. + enum { - AFNetworkReachabilityStatusUnknown, - AFNetworkReachabilityStatusNotReachable, - AFNetworkReachabilityStatusReachableViaWWAN, - AFNetworkReachabilityStatusReachableViaWiFi, + AFNetworkReachabilityStatusUnknown, + AFNetworkReachabilityStatusNotReachable, + AFNetworkReachabilityStatusReachableViaWWAN, + AFNetworkReachabilityStatusReachableViaWiFi, } - - `AFNetworkReachabilityStatusUnknown` - The `baseURL` host reachability is not known. - + + `AFNetworkReachabilityStatusUnknown` + The `baseURL` host reachability is not known. + `AFNetworkReachabilityStatusNotReachable` - The `baseURL` host cannot be reached. - + The `baseURL` host cannot be reached. + `AFNetworkReachabilityStatusReachableViaWWAN` - The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. - + The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. + `AFNetworkReachabilityStatusReachableViaWiFi` - The `baseURL` host can be reached via a Wi-Fi connection. - + The `baseURL` host can be reached via a Wi-Fi connection. + ### Keys for Notification UserInfo Dictionary - + Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. - + `AFNetworkingReachabilityNotificationStatusItem` - A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. - The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. - + A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. + The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. + ### Parameter Encoding - + The following constants are provided by `AFHTTPClient` as possible methods for serializing parameters into query string or message body values. enum { - AFFormURLParameterEncoding, - AFJSONParameterEncoding, - AFPropertyListParameterEncoding, + AFFormURLParameterEncoding, + AFJSONParameterEncoding, + AFPropertyListParameterEncoding, } - + `AFFormURLParameterEncoding` - Parameters are encoded into field/key pairs in the URL query string for `GET` `HEAD` and `DELETE` requests, and in the message body otherwise. Dictionary keys are sorted with the `caseInsensitiveCompare:` selector of their description, in order to mitigate the possibility of ambiguous query strings being generated non-deterministically. See the warning for the `parameterEncoding` property for additional information. - + Parameters are encoded into field/key pairs in the URL query string for `GET` `HEAD` and `DELETE` requests, and in the message body otherwise. Dictionary keys are sorted with the `caseInsensitiveCompare:` selector of their description, in order to mitigate the possibility of ambiguous query strings being generated non-deterministically. See the warning for the `parameterEncoding` property for additional information. + `AFJSONParameterEncoding` - Parameters are encoded into JSON in the message body. - - `AFPropertyListParameterEncoding` - Parameters are encoded into a property list in the message body. + Parameters are encoded into JSON in the message body. + + `AFPropertyListParameterEncoding` + Parameters are encoded into a property list in the message body. */ ///---------------- @@ -497,14 +497,14 @@ typedef enum { /** Returns a query string constructed by a set of parameters, using the specified encoding. - + @param parameters The parameters used to construct the query string @param encoding The encoding to use in constructing the query string. If you are uncertain of the correct encoding, you should use UTF-8 (`NSUTF8StringEncoding`), which is the encoding designated by RFC 3986 as the correct encoding for use in URLs. - + @discussion Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&". - + If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component. - + @return A percent-escaped query string */ extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding); @@ -516,7 +516,7 @@ extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *paramete /** Posted when network reachability changes. This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability. - + @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). */ #ifdef _SYSTEMCONFIGURATION_H @@ -536,13 +536,13 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; /** Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary. - + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. @param name The name to be associated with the specified data. This parameter must not be `nil`. @param error If an error occurs, upon return contains an `NSError` object that describes the problem. - + @return `YES` if the file data was successfully appended, otherwise `NO`. - + @discussion The filename and MIME type for this data in the form will be automatically generated, using `NSURLResponse` `-suggestedFilename` and `-MIMEType`, respectively. */ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL @@ -551,7 +551,7 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; /** Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. - + @param data The data to be encoded and appended to the form data. @param name The name to be associated with the specified data. This parameter must not be `nil`. @param filename The filename to be associated with the specified data. This parameter must not be `nil`. @@ -564,7 +564,7 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; /** Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary. - + @param data The data to be encoded and appended to the form data. @param name The name to be associated with the specified data. This parameter must not be `nil`. */ @@ -574,7 +574,7 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; /** Appends HTTP headers, followed by the encoded data and the multipart form boundary. - + @param headers The HTTP headers to be appended to the form data. @param body The data to be encoded and appended to the form data. */ @@ -583,10 +583,10 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; /** Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. - + @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 32kb. @param delay Duration of delay each time a packet is read. By default, no delay is set. - + @discussion When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. */ - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index d9a066b424..a7b9569b3e 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -28,15 +28,15 @@ #import #ifdef _SYSTEMCONFIGURATION_H - #import - #import - #import - #import - #import +#import +#import +#import +#import +#import #endif #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - #import +#import #endif #ifdef _SYSTEMCONFIGURATION_H @@ -55,10 +55,10 @@ NSData *data = [NSData dataWithBytes:[string UTF8String] length:[string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]]; NSUInteger length = [data length]; NSMutableData *mutableData = [NSMutableData dataWithLength:((length + 2) / 3) * 4]; - + uint8_t *input = (uint8_t *)[data bytes]; uint8_t *output = (uint8_t *)[mutableData mutableBytes]; - + for (NSUInteger i = 0; i < length; i += 3) { NSUInteger value = 0; for (NSUInteger j = i; j < (i + 3); j++) { @@ -67,23 +67,23 @@ value |= (0xFF & input[j]); } } - + static uint8_t const kAFBase64EncodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - + NSUInteger idx = (i / 3) * 4; output[idx + 0] = kAFBase64EncodingTable[(value >> 18) & 0x3F]; output[idx + 1] = kAFBase64EncodingTable[(value >> 12) & 0x3F]; output[idx + 2] = (i + 1) < length ? kAFBase64EncodingTable[(value >> 6) & 0x3F] : '='; output[idx + 3] = (i + 2) < length ? kAFBase64EncodingTable[(value >> 0) & 0x3F] : '='; } - + return [[NSString alloc] initWithData:mutableData encoding:NSASCIIStringEncoding]; } static NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { static NSString * const kAFCharactersToBeEscaped = @":/?&=;+!@#$()~'"; static NSString * const kAFCharactersToLeaveUnescaped = @"[]."; - + return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, (__bridge CFStringRef)kAFCharactersToLeaveUnescaped, (__bridge CFStringRef)kAFCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)); } @@ -107,10 +107,10 @@ - (id)initWithField:(id)field value:(id)value { if (!self) { return nil; } - + self.field = field; self.value = value; - + return self; } @@ -134,7 +134,7 @@ - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { [mutablePairs addObject:[pair URLEncodedStringValueWithEncoding:stringEncoding]]; } - + return [mutablePairs componentsJoinedByString:@"&"]; } @@ -144,7 +144,7 @@ - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; - + if ([value isKindOfClass:[NSDictionary class]]) { // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(caseInsensitiveCompare:)]; @@ -162,7 +162,7 @@ - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding } else { [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; } - + return mutableQueryStringComponents; } @@ -213,45 +213,45 @@ + (instancetype)clientWithBaseURL:(NSURL *)url { - (id)initWithBaseURL:(NSURL *)url { NSParameterAssert(url); - + self = [super init]; if (!self) { return nil; } - + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { url = [url URLByAppendingPathComponent:@""]; } - + self.baseURL = url; - + self.stringEncoding = NSUTF8StringEncoding; self.parameterEncoding = AFFormURLParameterEncoding; - + self.registeredHTTPOperationClassNames = [NSMutableArray array]; - + self.defaultHeaders = [NSMutableDictionary dictionary]; - + // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 NSString *preferredLanguageCodes = [[NSLocale preferredLanguages] componentsJoinedByString:@", "]; [self setDefaultHeader:@"Accept-Language" value:[NSString stringWithFormat:@"%@, en-us;q=0.8", preferredLanguageCodes]]; - + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0f)]]; #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]]; #endif - + #ifdef _SYSTEMCONFIGURATION_H self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; [self startMonitoringNetworkReachability]; #endif - + self.operationQueue = [[NSOperationQueue alloc] init]; [self.operationQueue setMaxConcurrentOperationCount:NSOperationQueueDefaultMaxConcurrentOperationCount]; - + return self; } @@ -271,7 +271,7 @@ - (NSString *)description { static BOOL AFURLHostIsIPAddress(NSURL *url) { struct sockaddr_in sa_in; struct sockaddr_in6 sa_in6; - + return [url host] && (inet_pton(AF_INET, [[url host] UTF8String], &sa_in) == 1 || inet_pton(AF_INET6, [[url host] UTF8String], &sa_in6) == 1); } @@ -279,7 +279,7 @@ static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetwork BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); BOOL isNetworkReachable = (isReachable && !needsConnection); - + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; if (isNetworkReachable == NO) { status = AFNetworkReachabilityStatusNotReachable; @@ -292,7 +292,7 @@ static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetwork else { status = AFNetworkReachabilityStatusReachableViaWiFi; } - + return status; } @@ -302,7 +302,7 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ if (block) { block(status); } - + dispatch_async(dispatch_get_main_queue(), ^{ [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; }); @@ -320,34 +320,34 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) { - (void)startMonitoringNetworkReachability { [self stopMonitoringNetworkReachability]; - + if (!self.baseURL) { return; } - + self.networkReachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [[self.baseURL host] UTF8String]); - + if (!self.networkReachability) { return; } - + __weak __typeof(&*self)weakSelf = self; AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { __strong __typeof(&*weakSelf)strongSelf = weakSelf; if (!strongSelf) { return; } - + strongSelf.networkReachabilityStatus = status; if (strongSelf.networkReachabilityStatusBlock) { strongSelf.networkReachabilityStatusBlock(status); } }; - + SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes); - + /* Network reachability monitoring does not establish a baseline for IP addresses as it does for hostnames, so if the base URL host is an IP address, the initial reachability callback is manually triggered. */ if (AFURLHostIsIPAddress(self.baseURL)) { @@ -379,11 +379,11 @@ - (BOOL)registerHTTPOperationClass:(Class)operationClass { if (![operationClass isSubclassOfClass:[AFHTTPRequestOperation class]]) { return NO; } - + NSString *className = NSStringFromClass(operationClass); [self.registeredHTTPOperationClassNames removeObject:className]; [self.registeredHTTPOperationClassNames insertObject:className atIndex:0]; - + return YES; } @@ -422,16 +422,16 @@ - (NSMutableURLRequest *)requestWithMethod:(NSString *)method parameters:(NSDictionary *)parameters { NSParameterAssert(method); - + if (!path) { path = @""; } - + NSURL *url = [NSURL URLWithString:path relativeToURL:self.baseURL]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; [request setHTTPMethod:method]; [request setAllHTTPHeaderFields:self.defaultHeaders]; - + if (parameters) { if ([method isEqualToString:@"GET"] || [method isEqualToString:@"HEAD"] || [method isEqualToString:@"DELETE"]) { url = [NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:[path rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding)]]; @@ -439,7 +439,7 @@ - (NSMutableURLRequest *)requestWithMethod:(NSString *)method } else { NSString *charset = (__bridge NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding)); NSError *error = nil; - + switch (self.parameterEncoding) { case AFFormURLParameterEncoding:; [request setValue:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%@", charset] forHTTPHeaderField:@"Content-Type"]; @@ -454,13 +454,13 @@ - (NSMutableURLRequest *)requestWithMethod:(NSString *)method [request setHTTPBody:[NSPropertyListSerialization dataWithPropertyList:parameters format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]]; break; } - + if (error) { NSLog(@"%@ %@: %@", [self class], NSStringFromSelector(_cmd), error); } } } - + return request; } @@ -471,11 +471,11 @@ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method { NSParameterAssert(method); NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]); - + NSMutableURLRequest *request = [self requestWithMethod:method path:path parameters:nil]; - + __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:request stringEncoding:self.stringEncoding]; - + if (parameters) { for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { NSData *data = nil; @@ -486,17 +486,17 @@ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method } else { data = [[pair.value description] dataUsingEncoding:self.stringEncoding]; } - + if (data) { [formData appendPartWithFormData:data name:[pair.field description]]; } } } - + if (block) { block(formData); } - + return [formData requestByFinalizingMultipartFormData]; } @@ -513,15 +513,15 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR operation = [(AFHTTPRequestOperation *)[op_class alloc] initWithRequest:urlRequest]; } } - + if (!operation) { operation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; } - + [operation setCompletionBlockWithSuccess:success failure:failure]; operation.credential = self.defaultCredential; - + return operation; } @@ -535,15 +535,15 @@ - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path { NSString *URLStringToMatched = [[[self requestWithMethod:(method ?: @"GET") path:path parameters:nil] URL] absoluteString]; - + for (NSOperation *operation in [self.operationQueue operations]) { if (![operation isKindOfClass:[AFHTTPRequestOperation class]]) { continue; } - + BOOL hasMatchingMethod = !method || [method isEqualToString:[[(AFHTTPRequestOperation *)operation request] HTTPMethod]]; BOOL hasMatchingURL = [[[[(AFHTTPRequestOperation *)operation request] URL] absoluteString] isEqualToString:URLStringToMatched]; - + if (hasMatchingMethod && hasMatchingURL) { [operation cancel]; } @@ -559,7 +559,7 @@ - (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:nil failure:nil]; [mutableOperations addObject:operation]; } - + [self enqueueBatchOfHTTPRequestOperations:mutableOperations progressBlock:progressBlock completionBlock:completionBlock]; } @@ -578,7 +578,7 @@ - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations dispatch_release(dispatchGroup); #endif }]; - + for (AFHTTPRequestOperation *operation in operations) { AFCompletionBlock originalCompletionBlock = [operation.completionBlock copy]; __weak AFHTTPRequestOperation *weakOperation = operation; @@ -588,22 +588,22 @@ - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations if (originalCompletionBlock) { originalCompletionBlock(); } - + __block NSUInteger numberOfFinishedOperations = 0; [operations enumerateObjectsUsingBlock:^(id obj, __unused NSUInteger idx, __unused BOOL *stop) { if ([(NSOperation *)obj isFinished]) { numberOfFinishedOperations++; } }]; - + if (progressBlock) { progressBlock(numberOfFinishedOperations, [operations count]); } - + dispatch_group_leave(dispatchGroup); }); }; - + dispatch_group_enter(dispatchGroup); [batchedOperation addDependency:operation]; } @@ -667,17 +667,17 @@ - (void)patchPath:(NSString *)path - (id)initWithCoder:(NSCoder *)aDecoder { NSURL *baseURL = [aDecoder decodeObjectForKey:@"baseURL"]; - + self = [self initWithBaseURL:baseURL]; if (!self) { return nil; } - + self.stringEncoding = [aDecoder decodeIntegerForKey:@"stringEncoding"]; self.parameterEncoding = [aDecoder decodeIntegerForKey:@"parameterEncoding"]; self.registeredHTTPOperationClassNames = [aDecoder decodeObjectForKey:@"registeredHTTPOperationClassNames"]; self.defaultHeaders = [aDecoder decodeObjectForKey:@"defaultHeaders"]; - + return self; } @@ -693,7 +693,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { - (id)copyWithZone:(NSZone *)zone { AFHTTPClient *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL]; - + HTTPClient.stringEncoding = self.stringEncoding; HTTPClient.parameterEncoding = self.parameterEncoding; HTTPClient.registeredHTTPOperationClassNames = [self.registeredHTTPOperationClassNames copyWithZone:zone]; @@ -786,11 +786,11 @@ - (id)initWithURLRequest:(NSMutableURLRequest *)urlRequest if (!self) { return nil; } - + self.request = urlRequest; self.stringEncoding = encoding; self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding]; - + return self; } @@ -800,27 +800,27 @@ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL { NSParameterAssert(fileURL); NSParameterAssert(name); - + if (![fileURL isFileURL]) { NSDictionary *userInfo = [NSDictionary dictionaryWithObject:NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil) forKey:NSLocalizedFailureReasonErrorKey]; if (error != NULL) { *error = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; } - + return NO; } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) { NSDictionary *userInfo = [NSDictionary dictionaryWithObject:NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil) forKey:NSLocalizedFailureReasonErrorKey]; if (error != NULL) { *error = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; } - + return NO; } - + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, [fileURL lastPathComponent]] forKey:@"Content-Disposition"]; [mutableHeaders setValue:AFContentTypeForPathExtension([fileURL pathExtension]) forKey:@"Content-Type"]; - + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; bodyPart.stringEncoding = self.stringEncoding; bodyPart.headers = mutableHeaders; @@ -828,9 +828,9 @@ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:nil]; bodyPart.bodyContentLength = [[fileAttributes objectForKey:NSFileSize] unsignedLongLongValue]; - + [self.bodyStream appendHTTPBodyPart:bodyPart]; - + return YES; } @@ -842,11 +842,11 @@ - (void)appendPartWithFileData:(NSData *)data NSParameterAssert(name); NSParameterAssert(fileName); NSParameterAssert(mimeType); - + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; - + [self appendPartWithHeaders:mutableHeaders body:data]; } @@ -854,10 +854,10 @@ - (void)appendPartWithFormData:(NSData *)data name:(NSString *)name { NSParameterAssert(name); - + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"]; - + [self appendPartWithHeaders:mutableHeaders body:data]; } @@ -865,13 +865,13 @@ - (void)appendPartWithHeaders:(NSDictionary *)headers body:(NSData *)body { NSParameterAssert(body); - + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; bodyPart.stringEncoding = self.stringEncoding; bodyPart.headers = headers; bodyPart.bodyContentLength = [body length]; bodyPart.body = body; - + [self.bodyStream appendHTTPBodyPart:bodyPart]; } @@ -886,14 +886,14 @@ - (NSMutableURLRequest *)requestByFinalizingMultipartFormData { if ([self.bodyStream isEmpty]) { return self.request; } - + // Reset the initial and final boundaries to ensure correct Content-Length [self.bodyStream setInitialAndFinalBoundaries]; - + [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", kAFMultipartFormBoundary] forHTTPHeaderField:@"Content-Type"]; [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"]; [self.request setHTTPBodyStream:self.bodyStream]; - + return self.request; } @@ -926,11 +926,11 @@ - (id)initWithStringEncoding:(NSStringEncoding)encoding { if (!self) { return nil; } - + self.stringEncoding = encoding; self.HTTPBodyParts = [NSMutableArray array]; self.numberOfBytesInPacket = NSIntegerMax; - + return self; } @@ -940,7 +940,7 @@ - (void)setInitialAndFinalBoundaries { bodyPart.hasInitialBoundary = NO; bodyPart.hasFinalBoundary = NO; } - + [[self.HTTPBodyParts objectAtIndex:0] setHasInitialBoundary:YES]; [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES]; } @@ -963,7 +963,7 @@ - (NSInteger)read:(uint8_t *)buffer return 0; } NSInteger bytesRead = 0; - + while ((NSUInteger)bytesRead < MIN(length, self.numberOfBytesInPacket)) { if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) { if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) { @@ -995,9 +995,9 @@ - (void)open { if (self.streamStatus == NSStreamStatusOpen) { return; } - + self.streamStatus = NSStreamStatusOpen; - + [self setInitialAndFinalBoundaries]; self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; } @@ -1029,7 +1029,7 @@ - (unsigned long long)contentLength { for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { length += [bodyPart contentLength]; } - + return length; } @@ -1099,9 +1099,9 @@ - (id)init { if (!self) { return nil; } - + [self transitionToNextPhase]; - + return self; } @@ -1130,24 +1130,24 @@ - (NSString *)stringForHeaders { [headerString appendString:[NSString stringWithFormat:@"%@: %@%@", field, [self.headers valueForKey:field], kAFMultipartFormCRLF]]; } [headerString appendString:kAFMultipartFormCRLF]; - + return [NSString stringWithString:headerString]; } - (unsigned long long)contentLength { unsigned long long length = 0; - + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary() : AFMultipartFormEncapsulationBoundary()) dataUsingEncoding:self.stringEncoding]; length += [encapsulationBoundaryData length]; - + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; length += [headersData length]; - + length += _bodyContentLength; - + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding] : [NSData data]); length += [closingBoundaryData length]; - + return length; } @@ -1156,7 +1156,7 @@ - (BOOL)hasBytesAvailable { if (_phase == AFFinalBoundaryPhase) { return YES; } - + switch (self.inputStream.streamStatus) { case NSStreamStatusNotOpen: case NSStreamStatusOpening: @@ -1176,27 +1176,27 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { NSInteger bytesRead = 0; - + if (_phase == AFEncapsulationBoundaryPhase) { NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary() : AFMultipartFormEncapsulationBoundary()) dataUsingEncoding:self.stringEncoding]; bytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; } - + if (_phase == AFHeaderPhase) { NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; bytesRead += [self readData:headersData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; } - + if (_phase == AFBodyPhase) { if ([self.inputStream hasBytesAvailable]) { bytesRead += [self.inputStream read:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; } - + if (![self.inputStream hasBytesAvailable]) { [self transitionToNextPhase]; } } - + if (_phase == AFFinalBoundaryPhase) { NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding] : [NSData data]); bytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; @@ -1211,13 +1211,13 @@ - (NSInteger)readData:(NSData *)data { NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length)); [data getBytes:buffer range:range]; - + _phaseReadOffset += range.length; - + if (((NSUInteger)_phaseReadOffset) >= [data length]) { [self transitionToNextPhase]; } - + return (NSInteger)range.length; } @@ -1226,7 +1226,7 @@ - (BOOL)transitionToNextPhase { [self performSelectorOnMainThread:@selector(transitionToNextPhase) withObject:nil waitUntilDone:YES]; return YES; } - + switch (_phase) { case AFEncapsulationBoundaryPhase: _phase = AFHeaderPhase; @@ -1246,7 +1246,7 @@ - (BOOL)transitionToNextPhase { break; } _phaseReadOffset = 0; - + return YES; } diff --git a/AFNetworking/AFHTTPRequestOperation.h b/AFNetworking/AFHTTPRequestOperation.h index d6776b3926..2ec99ac6bd 100644 --- a/AFNetworking/AFHTTPRequestOperation.h +++ b/AFNetworking/AFHTTPRequestOperation.h @@ -1,17 +1,17 @@ // AFHTTPRequestOperation.h // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -51,12 +51,12 @@ */ @property (nonatomic, readonly) BOOL hasAcceptableContentType; -/** +/** The callback dispatch queue on success. If `NULL` (default), the main queue is used. */ @property (nonatomic, assign) dispatch_queue_t successCallbackQueue; -/** +/** The callback dispatch queue on failure. If `NULL` (default), the main queue is used. */ @property (nonatomic, assign) dispatch_queue_t failureCallbackQueue; @@ -67,21 +67,21 @@ /** Returns an `NSIndexSet` object containing the ranges of acceptable HTTP status codes. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html - + By default, this is the range 200 to 299, inclusive. */ + (NSIndexSet *)acceptableStatusCodes; /** Adds status codes to the set of acceptable HTTP status codes returned by `+acceptableStatusCodes` in subsequent calls by this class and its descendants. - + @param statusCodes The status codes to be added to the set of acceptable HTTP status codes */ + (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes; /** - Returns an `NSSet` object containing the acceptable MIME types. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 - + Returns an `NSSet` object containing the acceptable MIME types. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 + By default, this is `nil`. */ + (NSSet *)acceptableContentTypes; @@ -100,7 +100,7 @@ /** A Boolean value determining whether or not the class can process the specified request. For example, `AFJSONRequestOperation` may check to make sure the content type was `application/json` or the URL path extension was `.json`. - + @param urlRequest The request that is determined to be supported or not supported for this class. */ + (BOOL)canProcessRequest:(NSURLRequest *)urlRequest; @@ -111,10 +111,10 @@ /** Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed. - + @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request. @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request. - + @discussion This method should be overridden in subclasses in order to specify the response object passed into the success block. */ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 091f05bf3f..d9cca8e770 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -1,17 +1,17 @@ // AFHTTPRequestOperation.m // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,12 +25,12 @@ // Workaround for change in imp_implementationWithBlock() with Xcode 4.5 #if defined(__IPHONE_6_0) || defined(__MAC_10_8) - #define AF_CAST_TO_BLOCK id +#define AF_CAST_TO_BLOCK id #else - #define AF_CAST_TO_BLOCK __bridge void * +#define AF_CAST_TO_BLOCK __bridge void * #endif -// We do a little bit of duck typing in this file which can trigger this warning. Turn it off for this source file. +// We do a little bit of duck typing in this file which can trigger this warning. Turn it off for this source file. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wstrict-selector-match" @@ -47,9 +47,9 @@ if (parametersRange.location != NSNotFound) { mediaRange = [mediaRange substringToIndex:parametersRange.location]; } - + mediaRange = [mediaRange stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - + if (mediaRange.length > 0) { [mutableContentTypes addObject:mediaRange]; } @@ -130,7 +130,7 @@ - (void)dealloc { #endif _successCallbackQueue = NULL; } - + if (_failureCallbackQueue) { #if !OS_OBJECT_USE_OBJC dispatch_release(_failureCallbackQueue); @@ -147,7 +147,7 @@ - (NSError *)error { [userInfo setValue:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; [userInfo setValue:self.request forKey:AFNetworkingOperationFailingURLRequestErrorKey]; [userInfo setValue:self.response forKey:AFNetworkingOperationFailingURLResponseErrorKey]; - + if (![self hasAcceptableStatusCode]) { NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200; [userInfo setValue:[NSString stringWithFormat:NSLocalizedStringFromTable(@"Expected status code in (%@), got %d", @"AFNetworking", nil), AFStringFromIndexSet([[self class] acceptableStatusCodes]), statusCode] forKey:NSLocalizedDescriptionKey]; @@ -161,7 +161,7 @@ - (NSError *)error { } } } - + if (self.HTTPError) { return self.HTTPError; } else { @@ -189,7 +189,7 @@ - (NSString *)responseString { } - (void)pause { - unsigned long long offset = 0; + unsigned long long offset = 0; if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) { offset = [[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue]; } else { @@ -202,7 +202,7 @@ - (void)pause { } [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"]; self.request = mutableURLRequest; - + [super pause]; } @@ -210,7 +210,7 @@ - (BOOL)hasAcceptableStatusCode { if (!self.response) { return NO; } - + NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200; return ![[self class] acceptableStatusCodes] || [[[self class] acceptableStatusCodes] containsIndex:statusCode]; } @@ -219,14 +219,14 @@ - (BOOL)hasAcceptableContentType { if (!self.response) { return NO; } - + // Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its content and/or the name extension(s) of the URI used to identify the resource. If the media type remains unknown, the recipient SHOULD treat it as type "application/octet-stream". // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html NSString *contentType = [self.response MIMEType]; if (!contentType) { contentType = @"application/octet-stream"; } - + return ![[self class] acceptableContentTypes] || [[[self class] acceptableContentTypes] containsObject:contentType]; } @@ -245,7 +245,7 @@ - (void)setSuccessCallbackQueue:(dispatch_queue_t)successCallbackQueue { #endif _successCallbackQueue = successCallbackQueue; } - } + } } - (void)setFailureCallbackQueue:(dispatch_queue_t)failureCallbackQueue { @@ -256,14 +256,14 @@ - (void)setFailureCallbackQueue:(dispatch_queue_t)failureCallbackQueue { #endif _failureCallbackQueue = NULL; } - + if (failureCallbackQueue) { #if !OS_OBJECT_USE_OBJC dispatch_retain(failureCallbackQueue); #endif _failureCallbackQueue = failureCallbackQueue; } - } + } } - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success @@ -320,17 +320,17 @@ + (BOOL)canProcessRequest:(NSURLRequest *)request { if ([[self class] isEqual:[AFHTTPRequestOperation class]]) { return YES; } - + return [[self acceptableContentTypes] intersectsSet:AFContentTypesFromHTTPHeader([request valueForHTTPHeaderField:@"Accept"])]; } #pragma mark - NSURLConnectionDelegate -- (void)connection:(__unused NSURLConnection *)connection -didReceiveResponse:(NSURLResponse *)response +- (void)connection:(__unused NSURLConnection *)connection +didReceiveResponse:(NSURLResponse *)response { self.response = (NSHTTPURLResponse *)response; - + // Set Content-Range header if status code of response is 206 (Partial Content) // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.7 long long totalContentLength = self.response.expectedContentLength; @@ -351,7 +351,7 @@ - (void)connection:(__unused NSURLConnection *)connection } else { if ([[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length] > 0) { self.outputStream = [NSOutputStream outputStreamToMemory]; - + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; for (NSString *runLoopMode in self.runLoopModes) { [self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode]; @@ -359,7 +359,7 @@ - (void)connection:(__unused NSURLConnection *)connection } } } - + self.offsetContentLength = MAX(fileOffset, 0); self.totalContentLength = totalContentLength; diff --git a/AFNetworking/AFImageRequestOperation.h b/AFNetworking/AFImageRequestOperation.h index d991b2509f..68b28ed3b2 100644 --- a/AFNetworking/AFImageRequestOperation.h +++ b/AFNetworking/AFImageRequestOperation.h @@ -1,17 +1,17 @@ // AFImageRequestOperation.h // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -26,18 +26,18 @@ #import #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - #import +#import #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) - #import +#import #endif /** `AFImageRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading an processing images. - + ## Acceptable Content Types - + By default, `AFImageRequestOperation` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: - + - `image/tiff` - `image/jpeg` - `image/gif` @@ -69,28 +69,28 @@ /** Creates and returns an `AFImageRequestOperation` object and sets the specified success callback. - + @param urlRequest The request object to be loaded asynchronously during execution of the operation. @param success A block object to be executed when the request finishes successfully. This block has no return value and takes a single arguments, the image created from the response data of the request. - + @return A new image request operation */ #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(UIImage *image))success; #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(NSImage *image))success; #endif /** Creates and returns an `AFImageRequestOperation` object and sets the specified success callback. - + @param urlRequest The request object to be loaded asynchronously during execution of the operation. @param imageProcessingBlock A block object to be executed after the image request finishes successfully, but before the image is returned in the `success` block. This block takes a single argument, the image loaded from the response body, and returns the processed image. @param success A block object to be executed when the request finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the image created from the response data. @param failure A block object to be executed when the request finishes unsuccessfully. This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the error associated with the cause for the unsuccessful operation. - + @return A new image request operation */ #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index 1eca51e1b6..e39c9d6f86 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -1,17 +1,17 @@ // AFImageRequestOperation.m // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -27,7 +27,7 @@ static dispatch_queue_t image_request_operation_processing_queue() { if (af_image_request_operation_processing_queue == NULL) { af_image_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.image-request.processing", 0); } - + return af_image_request_operation_processing_queue; } @@ -46,7 +46,7 @@ @implementation AFImageRequestOperation #endif #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(UIImage *image))success { return [self imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil success:^(NSURLRequest __unused *request, NSHTTPURLResponse __unused *response, UIImage *image) { @@ -56,7 +56,7 @@ + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest } failure:nil]; } #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -+ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(NSImage *image))success { return [self imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil success:^(NSURLRequest __unused *request, NSHTTPURLResponse __unused *response, NSImage *image) { @@ -95,8 +95,8 @@ + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest failure(operation.request, operation.response, error); } }]; - - + + return requestOperation; } #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) @@ -126,7 +126,7 @@ + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest failure(operation.request, operation.response, error); } }]; - + return requestOperation; } #endif @@ -136,11 +136,11 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest { if (!self) { return nil; } - + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) self.imageScale = [[UIScreen mainScreen] scale]; #endif - + return self; } @@ -149,10 +149,10 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest { - (UIImage *)responseImage { if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) { UIImage *image = [UIImage imageWithData:self.responseData]; - + self.responseImage = [UIImage imageWithCGImage:[image CGImage] scale:self.imageScale orientation:image.imageOrientation]; } - + return _responseImage; } @@ -163,9 +163,9 @@ - (void)setImageScale:(CGFloat)imageScale { return; } #pragma clang diagnostic pop - + _imageScale = imageScale; - + self.responseImage = nil; } #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) @@ -176,7 +176,7 @@ - (NSImage *)responseImage { self.responseImage = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])]; [self.responseImage addRepresentation:bitimage]; } - + return _responseImage; } #endif @@ -193,8 +193,8 @@ + (BOOL)canProcessRequest:(NSURLRequest *)request { dispatch_once(&onceToken, ^{ _acceptablePathExtension = [[NSSet alloc] initWithObjects:@"tif", @"tiff", @"jpg", @"jpeg", @"gif", @"png", @"ico", @"bmp", @"cur", nil]; }); - - return [_acceptablePathExtension containsObject:[[request URL] pathExtension]] || [super canProcessRequest:request]; + + return [_acceptablePathExtension containsObject:[[request URL] pathExtension]] || [super canProcessRequest:request]; } - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success @@ -210,7 +210,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio failure(self, self.error); }); } - } else { + } else { if (success) { #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) UIImage *image = nil; diff --git a/AFNetworking/AFJSONRequestOperation.h b/AFNetworking/AFJSONRequestOperation.h index d625cb2501..5493a40775 100644 --- a/AFNetworking/AFJSONRequestOperation.h +++ b/AFNetworking/AFJSONRequestOperation.h @@ -65,7 +65,7 @@ @return A new JSON request operation */ + (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure; + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure; @end diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 3807a0bfe9..bb893b5a06 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -1,17 +1,17 @@ // AFJSONRequestOperation.m // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -27,7 +27,7 @@ static dispatch_queue_t json_request_operation_processing_queue() { if (af_json_request_operation_processing_queue == NULL) { af_json_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.json-request.processing", 0); } - + return af_json_request_operation_processing_queue; } @@ -55,7 +55,7 @@ + (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest failure(operation.request, operation.response, error, [(AFJSONRequestOperation *)operation responseJSON]); } }]; - + return requestOperation; } @@ -74,10 +74,10 @@ - (id)responseJSON { NSData *JSONData = [self.responseString dataUsingEncoding:self.responseStringEncoding]; self.responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:self.JSONReadingOptions error:&error]; } - + self.JSONError = error; } - + return _responseJSON; } @@ -104,7 +104,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" - self.completionBlock = ^ { + self.completionBlock = ^ { if (self.error) { if (failure) { dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ @@ -114,7 +114,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio } else { dispatch_async(json_request_operation_processing_queue(), ^{ id JSON = self.responseJSON; - + if (self.JSONError) { if (failure) { dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ @@ -126,7 +126,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ success(self, JSON); }); - } + } } }); } diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.h b/AFNetworking/AFNetworkActivityIndicatorManager.h index 59cabcd230..bac7b5a27c 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.h +++ b/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -1,17 +1,17 @@ // AFNetworkActivityIndicatorManager.h // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -29,21 +29,21 @@ /** `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. - + You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: - - [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; - + + [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; + By setting `isNetworkActivityIndicatorVisible` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. - + See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 */ @interface AFNetworkActivityIndicatorManager : NSObject /** - A Boolean value indicating whether the manager is enabled. - + A Boolean value indicating whether the manager is enabled. + @discussion If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. */ @property (nonatomic, assign, getter = isEnabled) BOOL enabled; @@ -51,11 +51,11 @@ /** A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. */ -@property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; +@property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; /** Returns the shared network activity indicator manager object for the system. - + @return The systemwide network activity indicator manager. */ + (instancetype)sharedManager; diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.m b/AFNetworking/AFNetworkActivityIndicatorManager.m index 8f4d8681b8..5b9ec822f1 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.m +++ b/AFNetworking/AFNetworkActivityIndicatorManager.m @@ -1,17 +1,17 @@ // AFNetworkActivityIndicatorManager.m // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -48,7 +48,7 @@ + (instancetype)sharedManager { dispatch_once(&oncePredicate, ^{ _sharedManager = [[self alloc] init]; }); - + return _sharedManager; } @@ -61,18 +61,18 @@ - (id)init { if (!self) { return nil; } - + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(incrementActivityCount) name:AFNetworkingOperationDidStartNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(decrementActivityCount) name:AFNetworkingOperationDidFinishNotification object:nil]; - + return self; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - + [_activityIndicatorVisibilityTimer invalidate]; - + } - (void)updateNetworkActivityIndicatorVisibilityDelayed { diff --git a/AFNetworking/AFPropertyListRequestOperation.h b/AFNetworking/AFPropertyListRequestOperation.h index 04fe6223fa..9ebb605743 100644 --- a/AFNetworking/AFPropertyListRequestOperation.h +++ b/AFNetworking/AFPropertyListRequestOperation.h @@ -1,17 +1,17 @@ // AFPropertyListRequestOperation.h // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,11 +25,11 @@ /** `AFPropertyListRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and deserializing objects with property list (plist) response data. - + ## Acceptable Content Types - + By default, `AFPropertyListRequestOperation` accepts the following MIME types: - + - `application/x-plist` */ @interface AFPropertyListRequestOperation : AFHTTPRequestOperation @@ -54,11 +54,11 @@ /** Creates and returns an `AFPropertyListRequestOperation` object and sets the specified success and failure callbacks. - + @param urlRequest The request object to be loaded asynchronously during execution of the operation @param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the object deserialized from a plist constructed using the response data. @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while deserializing the object from a property list. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network or parsing error that occurred. - + @return A new property list request operation */ + (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)urlRequest diff --git a/AFNetworking/AFPropertyListRequestOperation.m b/AFNetworking/AFPropertyListRequestOperation.m index 2eac6b65df..38229ce8e4 100644 --- a/AFNetworking/AFPropertyListRequestOperation.m +++ b/AFNetworking/AFPropertyListRequestOperation.m @@ -1,17 +1,17 @@ // AFPropertyListRequestOperation.m // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -27,7 +27,7 @@ static dispatch_queue_t property_list_request_operation_processing_queue() { if (af_property_list_request_operation_processing_queue == NULL) { af_property_list_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.property-list-request.processing", 0); } - + return af_property_list_request_operation_processing_queue; } @@ -57,7 +57,7 @@ + (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)request failure(operation.request, operation.response, error, [(AFPropertyListRequestOperation *)operation responsePropertyList]); } }]; - + return requestOperation; } @@ -66,9 +66,9 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest { if (!self) { return nil; } - + self.propertyListReadOptions = NSPropertyListImmutable; - + return self; } @@ -81,7 +81,7 @@ - (id)responsePropertyList { self.propertyListFormat = format; self.propertyListError = error; } - + return _responsePropertyList; } @@ -108,7 +108,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" - self.completionBlock = ^ { + self.completionBlock = ^ { if (self.error) { if (failure) { dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ @@ -118,7 +118,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio } else { dispatch_async(property_list_request_operation_processing_queue(), ^(void) { id propertyList = self.responsePropertyList; - + if (self.propertyListError) { if (failure) { dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ @@ -130,7 +130,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ success(self, propertyList); }); - } + } } }); } diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 27d9969764..ff4130d4e4 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -1,17 +1,17 @@ // AFURLConnectionOperation.h // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -26,17 +26,17 @@ /** `AFURLConnectionOperation` is a subclass of `NSOperation` that implements `NSURLConnection` delegate methods. - + ## Subclassing Notes - + This is the base class of all network request operations. You may wish to create your own subclass in order to implement additional `NSURLConnection` delegate methods (see "`NSURLConnection` Delegate Methods" below), or to provide additional properties and/or class constructors. - + If you are creating a subclass that communicates over the HTTP or HTTPS protocols, you may want to consider subclassing `AFHTTPRequestOperation` instead, as it supports specifying acceptable content types or status codes. - + ## NSURLConnection Delegate Methods - + `AFURLConnectionOperation` implements the following `NSURLConnection` delegate methods: - + - `connection:didReceiveResponse:` - `connection:didReceiveData:` - `connectionDidFinishLoading:` @@ -47,30 +47,30 @@ - `connection:didReceiveAuthenticationChallenge:` - `connectionShouldUseCredentialStorage:` - `connection:needNewBodyStream:` - + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. - + ## Class Constructors - + Class constructors, or methods that return an unowned instance, are the preferred way for subclasses to encapsulate any particular logic for handling the setup or parsing of response data. For instance, `AFJSONRequestOperation` provides `JSONRequestOperationWithRequest:success:failure:`, which takes block arguments, whose parameter on for a successful request is the JSON object initialized from the `response data`. - + ## Callbacks and Completion Blocks - + The built-in `completionBlock` provided by `NSOperation` allows for custom behavior to be executed after the request finishes. It is a common pattern for class constructors in subclasses to take callback block parameters, and execute them conditionally in the body of its `completionBlock`. Make sure to handle cancelled operations appropriately when setting a `completionBlock` (i.e. returning early before parsing response data). See the implementation of any of the `AFHTTPRequestOperation` subclasses for an example of this. - + Subclasses are strongly discouraged from overriding `setCompletionBlock:`, as `AFURLConnectionOperation`'s implementation includes a workaround to mitigate retain cycles, and what Apple rather ominously refers to as ["The Deallocation Problem"](http://developer.apple.com/library/ios/#technotes/tn2109/). - + ## NSCoding & NSCopying Conformance - + `AFURLConnectionOperation` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. However, because of the intrinsic limitations of capturing the exact state of an operation at a particular moment, there are some important caveats to keep in mind: - + ### NSCoding Caveats - + - Encoded operations do not include any block or stream properties. Be sure to set `completionBlock`, `outputStream`, and any callback blocks as necessary when using `-initWithCoder:` or `NSKeyedUnarchiver`. - Operations are paused on `encodeWithCoder:`. If the operation was encoded while paused or still executing, its archived state will return `YES` for `isReady`. Otherwise, the state of an operation when encoding will remain unchanged. - + ### NSCopying Caveats - + - `-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 would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. @@ -110,7 +110,7 @@ ///---------------------------- /** - The data received during the request. + The data received during the request. */ @property (readonly, nonatomic, strong) NSData *responseData; @@ -121,8 +121,8 @@ /** The string encoding of the response. - - @discussion If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. + + @discussion If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. */ @property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; @@ -133,14 +133,14 @@ /** Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. - + @discussion This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. */ @property (nonatomic, assign) BOOL shouldUseCredentialStorage; /** The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. - + @discussion This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. */ @property (nonatomic, strong) NSURLCredential *credential; @@ -150,15 +150,15 @@ ///------------------------ /** - The input stream used to read data to be sent during the request. - + The input stream used to read data to be sent during the request. + @discussion This property acts as a proxy to the `HTTPBodyStream` property of `request`. */ @property (nonatomic, strong) NSInputStream *inputStream; /** The output stream that is used to write data received until the request is finished. - + @discussion By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set. */ @property (nonatomic, strong) NSOutputStream *outputStream; @@ -178,9 +178,9 @@ /** Initializes and returns a newly allocated operation object with a url connection configured with the specified url request. - + @param urlRequest The request object to be used by the operation connection. - + @discussion This is the designated initializer. */ - (id)initWithRequest:(NSURLRequest *)urlRequest; @@ -191,21 +191,21 @@ /** Pauses the execution of the request operation. - + @discussion A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect. */ - (void)pause; /** Whether the request operation is currently paused. - + @return `YES` if the operation is currently paused, otherwise `NO`. */ - (BOOL)isPaused; /** Resumes the execution of the paused request operation. - + @discussion Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request. */ - (void)resume; @@ -216,8 +216,8 @@ /** Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task. - - @param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified. + + @param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified. */ #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler; @@ -229,14 +229,14 @@ /** Sets a callback to be called when an undetermined number of bytes have been uploaded to the server. - + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. */ - (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block; /** Sets a callback to be called when an undetermined number of bytes have been downloaded from the server. - + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. */ - (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block; @@ -247,25 +247,25 @@ /** Sets a block to be executed to determine whether the connection should be able to respond to a protection space's form of authentication, as handled by the `NSURLConnectionDelegate` method `connection:canAuthenticateAgainstProtectionSpace:`. - + @param block A block object to be executed to determine whether the connection should be able to respond to a protection space's form of authentication. The block has a `BOOL` return type and takes two arguments: the URL connection object, and the protection space to authenticate against. - + @discussion If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. */ - (void)setAuthenticationAgainstProtectionSpaceBlock:(BOOL (^)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace))block; /** Sets a block to be executed when the connection must authenticate a challenge in order to download its request, as handled by the `NSURLConnectionDelegate` method `connection:didReceiveAuthenticationChallenge:`. - + @param block A block object to be executed when the connection must authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. - + @discussion If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. */ - (void)setAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; /** Sets a block to be executed when the server redirects the request from one URL to another URL, or when the request URL changed by the `NSURLProtocol` subclass handling the request in order to standardize its format, as handled by the `NSURLConnectionDelegate` method `connection:willSendRequest:redirectResponse:`. - + @param block A block object to be executed when the request URL was changed. The block returns an `NSURLRequest` object, the URL request to redirect, and takes three arguments: the URL connection object, the the proposed redirected request, and the URL response that caused the redirect. */ - (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block; @@ -273,7 +273,7 @@ /** Sets a block to be executed to modify the response a connection will cache, if any, as handled by the `NSURLConnectionDelegate` method `connection:willCacheResponse:`. - + @param block A block object to be executed to determine what response a connection will cache, if any. The block returns an `NSCachedURLResponse` object, the cached response to store in memory or `nil` to prevent the response from being cached, and takes two arguments: the URL connection object, and the cached response provided for the request. */ - (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block; @@ -286,28 +286,28 @@ /** ## User info dictionary keys - + These keys may exist in the user info dictionary, in addition to those defined for NSError. - + - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey` - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` - + ### Constants - + `AFNetworkingOperationFailingURLRequestErrorKey` The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFNetworkingErrorDomain`. - + `AFNetworkingOperationFailingURLResponseErrorKey` The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFNetworkingErrorDomain`. - + ## Error Domains - + The following error domain is predefined. - + - `NSString * const AFNetworkingErrorDomain` - + ### Constants - + `AFNetworkingErrorDomain` AFNetworking errors. Error codes for `AFNetworkingErrorDomain` correspond to codes in `NSURLErrorDomain`. */ diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 8c4edf2a16..ad2809ef9b 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -1,17 +1,17 @@ // AFURLConnectionOperation.m // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -23,7 +23,7 @@ #import "AFURLConnectionOperation.h" #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - #import +#import #endif #if !__has_feature(objc_arc) @@ -167,19 +167,19 @@ + (void) __attribute__((noreturn)) networkRequestThreadEntryPoint:(id)__unused o + (NSThread *)networkRequestThread { static NSThread *_networkRequestThread = nil; static dispatch_once_t oncePredicate; - + dispatch_once(&oncePredicate, ^{ _networkRequestThread = [[NSThread alloc] initWithTarget:self selector:@selector(networkRequestThreadEntryPoint:) object:nil]; [_networkRequestThread start]; }); - + return _networkRequestThread; } + (NSArray *)pinnedCertificates { static NSArray *_pinnedCertificates = nil; static dispatch_once_t onceToken; - + dispatch_once(&onceToken, ^{ NSBundle *bundle = [NSBundle bundleForClass:[self class]]; NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; @@ -190,7 +190,7 @@ + (NSArray *)pinnedCertificates { } _pinnedCertificates = [[NSArray alloc] initWithArray:certificates]; }); - + return _pinnedCertificates; } @@ -199,20 +199,20 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest { if (!self) { return nil; } - + self.lock = [[NSRecursiveLock alloc] init]; self.lock.name = kAFNetworkingLockName; - + self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes]; - + self.request = urlRequest; self.shouldUseCredentialStorage = YES; - + self.outputStream = [NSOutputStream outputStreamToMemory]; self.state = AFOperationReadyState; - + return self; } @@ -242,7 +242,7 @@ - (void)setCompletionBlock:(void (^)(void))block { __weak __typeof(&*self)weakSelf = self; [super setCompletionBlock:^ { __strong __typeof(&*weakSelf)strongSelf = weakSelf; - + block(); [strongSelf setCompletionBlock:nil]; }]; @@ -266,7 +266,7 @@ - (void)setOutputStream:(NSOutputStream *)outputStream { if (outputStream == _outputStream) { return; } - + [self willChangeValueForKey:@"outputStream"]; if (_outputStream) { [_outputStream close]; @@ -278,19 +278,19 @@ - (void)setOutputStream:(NSOutputStream *)outputStream { #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler { [self.lock lock]; - if (!self.backgroundTaskIdentifier) { + if (!self.backgroundTaskIdentifier) { UIApplication *application = [UIApplication sharedApplication]; __weak __typeof(&*self)weakSelf = self; self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{ __strong __typeof(&*weakSelf)strongSelf = weakSelf; - + if (handler) { handler(); } - + if (strongSelf) { [strongSelf cancel]; - + [application endBackgroundTask:strongSelf.backgroundTaskIdentifier]; strongSelf.backgroundTaskIdentifier = UIBackgroundTaskInvalid; } @@ -329,13 +329,13 @@ - (void)setState:(AFOperationState)state { if (AFStateTransitionIsValid(self.state, state, [self isCancelled])) { NSString *oldStateKey = AFKeyPathFromOperationState(self.state); NSString *newStateKey = AFKeyPathFromOperationState(state); - + [self willChangeValueForKey:newStateKey]; [self willChangeValueForKey:oldStateKey]; _state = state; [self didChangeValueForKey:oldStateKey]; [self didChangeValueForKey:newStateKey]; - + dispatch_async(dispatch_get_main_queue(), ^{ switch (state) { case AFOperationExecutingState: @@ -358,7 +358,7 @@ - (NSString *)responseString { self.responseString = [[NSString alloc] initWithData:self.responseData encoding:self.responseStringEncoding]; } [self.lock unlock]; - + return _responseString; } @@ -372,11 +372,11 @@ - (NSStringEncoding)responseStringEncoding { stringEncoding = CFStringConvertEncodingToNSStringEncoding(IANAEncoding); } } - + self.responseStringEncoding = stringEncoding; } [self.lock unlock]; - + return _responseStringEncoding; } @@ -384,17 +384,17 @@ - (void)pause { if ([self isPaused] || [self isFinished] || [self isCancelled]) { return; } - + [self.lock lock]; - + if ([self isExecuting]) { [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - + dispatch_async(dispatch_get_main_queue(), ^{ [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; }); } - + self.state = AFOperationPausedState; [self.lock unlock]; @@ -408,10 +408,10 @@ - (void)resume { if (![self isPaused]) { return; } - + [self.lock lock]; self.state = AFOperationReadyState; - + [self start]; [self.lock unlock]; } @@ -438,7 +438,7 @@ - (void)start { [self.lock lock]; if ([self isReady]) { self.state = AFOperationExecutingState; - + [self performSelector:@selector(operationDidStart) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; } [self.lock unlock]; @@ -450,14 +450,14 @@ - (void)operationDidStart { [self finish]; } else { self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO]; - + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; for (NSString *runLoopMode in self.runLoopModes) { [self.connection scheduleInRunLoop:runLoop forMode:runLoopMode]; [self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode]; } - - [self.connection start]; + + [self.connection start]; } [self.lock unlock]; } @@ -474,7 +474,7 @@ - (void)cancel { [super cancel]; [self didChangeValueForKey:@"isCancelled"]; - // Cancel the connection on the thread it runs on to prevent race conditions + // Cancel the connection on the thread it runs on to prevent race conditions [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; } [self.lock unlock]; @@ -489,7 +489,7 @@ - (void)cancelConnection { if (self.connection) { [self.connection cancel]; - + // Manually send this delegate message since `[self.connection cancel]` causes the connection to never send another message to its delegate [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.error]; } @@ -505,7 +505,7 @@ - (void)connection:(NSURLConnection *)connection SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, 0); NSData *certificateData = (__bridge_transfer NSData *)SecCertificateCopyData(certificate); - + if ([[[self class] pinnedCertificates] containsObject:certificateData]) { NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; @@ -516,7 +516,7 @@ - (void)connection:(NSURLConnection *)connection } #endif -- (BOOL)connection:(NSURLConnection *)connection +- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { #ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ @@ -524,7 +524,7 @@ - (BOOL)connection:(NSURLConnection *)connection return YES; } #endif - + if (self.authenticationAgainstProtectionSpace) { return self.authenticationAgainstProtectionSpace(connection, protectionSpace); } else if ([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust] || [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodClientCertificate]) { @@ -534,8 +534,8 @@ - (BOOL)connection:(NSURLConnection *)connection } } -- (void)connection:(NSURLConnection *)connection -didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge +- (void)connection:(NSURLConnection *)connection +didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { #ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { @@ -543,7 +543,7 @@ - (void)connection:(NSURLConnection *)connection return; } #endif - + if (self.authenticationChallenge) { self.authenticationChallenge(connection, challenge); } else { @@ -564,7 +564,7 @@ - (void)connection:(NSURLConnection *)connection if (!credential) { credential = self.credential; } - + if (credential) { [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; } else { @@ -603,7 +603,7 @@ - (NSURLRequest *)connection:(NSURLConnection *)connection - (void)connection:(NSURLConnection __unused *)connection didSendBodyData:(NSInteger)bytesWritten - totalBytesWritten:(NSInteger)totalBytesWritten + totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite { if (self.uploadProgress) { @@ -614,10 +614,10 @@ - (void)connection:(NSURLConnection __unused *)connection } - (void)connection:(NSURLConnection __unused *)connection -didReceiveResponse:(NSURLResponse *)response +didReceiveResponse:(NSURLResponse *)response { self.response = response; - + [self.outputStream open]; } @@ -625,12 +625,12 @@ - (void)connection:(NSURLConnection __unused *)connection didReceiveData:(NSData *)data { self.totalBytesRead += [data length]; - + if ([self.outputStream hasSpaceAvailable]) { const uint8_t *dataBuffer = (uint8_t *) [data bytes]; [self.outputStream write:&dataBuffer[0] maxLength:[data length]]; } - + if (self.downloadProgress) { dispatch_async(dispatch_get_main_queue(), ^{ self.downloadProgress([data length], self.totalBytesRead, self.response.expectedContentLength); @@ -640,28 +640,28 @@ - (void)connection:(NSURLConnection __unused *)connection - (void)connectionDidFinishLoading:(NSURLConnection __unused *)connection { self.responseData = [self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey]; - + [self.outputStream close]; - + [self finish]; self.connection = nil; } - (void)connection:(NSURLConnection __unused *)connection - didFailWithError:(NSError *)error -{ + didFailWithError:(NSError *)error +{ self.error = error; - + [self.outputStream close]; - + [self finish]; self.connection = nil; } -- (NSCachedURLResponse *)connection:(NSURLConnection *)connection - willCacheResponse:(NSCachedURLResponse *)cachedResponse +- (NSCachedURLResponse *)connection:(NSURLConnection *)connection + willCacheResponse:(NSCachedURLResponse *)cachedResponse { if (self.cacheResponse) { return self.cacheResponse(connection, cachedResponse); @@ -669,8 +669,8 @@ - (NSCachedURLResponse *)connection:(NSURLConnection *)connection if ([self isCancelled]) { return nil; } - - return cachedResponse; + + return cachedResponse; } } @@ -678,7 +678,7 @@ - (NSCachedURLResponse *)connection:(NSURLConnection *)connection - (id)initWithCoder:(NSCoder *)aDecoder { NSURLRequest *request = [aDecoder decodeObjectForKey:@"request"]; - + self = [self initWithRequest:request]; if (!self) { return nil; @@ -690,13 +690,13 @@ - (id)initWithCoder:(NSCoder *)aDecoder { self.error = [aDecoder decodeObjectForKey:@"error"]; self.responseData = [aDecoder decodeObjectForKey:@"responseData"]; self.totalBytesRead = [[aDecoder decodeObjectForKey:@"totalBytesRead"] longLongValue]; - + return self; } - (void)encodeWithCoder:(NSCoder *)aCoder { [self pause]; - + [aCoder encodeObject:self.request forKey:@"request"]; switch (self.state) { @@ -708,7 +708,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeInteger:self.state forKey:@"state"]; break; } - + [aCoder encodeBool:[self isCancelled] forKey:@"isCancelled"]; [aCoder encodeObject:self.response forKey:@"response"]; [aCoder encodeObject:self.error forKey:@"error"]; @@ -720,14 +720,14 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { - (id)copyWithZone:(NSZone *)zone { AFURLConnectionOperation *operation = [(AFURLConnectionOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request]; - + operation.uploadProgress = self.uploadProgress; operation.downloadProgress = self.downloadProgress; operation.authenticationAgainstProtectionSpace = self.authenticationAgainstProtectionSpace; operation.authenticationChallenge = self.authenticationChallenge; operation.cacheResponse = self.cacheResponse; operation.redirectResponse = self.redirectResponse; - + return operation; } diff --git a/AFNetworking/AFXMLRequestOperation.h b/AFNetworking/AFXMLRequestOperation.h index 6a327f4f36..4130932e69 100644 --- a/AFNetworking/AFXMLRequestOperation.h +++ b/AFNetworking/AFXMLRequestOperation.h @@ -1,17 +1,17 @@ // AFXMLRequestOperation.h // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -27,16 +27,16 @@ /** `AFXMLRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and working with XML response data. - + ## Acceptable Content Types - + By default, `AFXMLRequestOperation` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: - + - `application/xml` - `text/xml` - + ## Use With AFHTTPClient - + When `AFXMLRequestOperation` is registered with `AFHTTPClient`, the response object in the success callback of `HTTPRequestOperationWithRequest:success:failure:` will be an instance of `NSXMLParser`. On platforms that support `NSXMLDocument`, you have the option to ignore the response object, and simply use the `responseXMLDocument` property of the operation argument of the callback. */ @interface AFXMLRequestOperation : AFHTTPRequestOperation @@ -59,11 +59,11 @@ /** Creates and returns an `AFXMLRequestOperation` object and sets the specified success and failure callbacks. - + @param urlRequest The request object to be loaded asynchronously during execution of the operation @param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the XML parser constructed with the response data of request. @param failure A block object to be executed when the operation finishes unsuccessfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network error that occurred. - + @return A new XML request operation */ + (instancetype)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest @@ -74,11 +74,11 @@ #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED /** Creates and returns an `AFXMLRequestOperation` object and sets the specified success and failure callbacks. - + @param urlRequest The request object to be loaded asynchronously during execution of the operation @param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the XML document created from the response data of request. @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data as XML. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network or parsing error that occurred. - + @return A new XML request operation */ + (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest diff --git a/AFNetworking/AFXMLRequestOperation.m b/AFNetworking/AFXMLRequestOperation.m index a95ad829d5..7e6b35266a 100644 --- a/AFNetworking/AFXMLRequestOperation.m +++ b/AFNetworking/AFXMLRequestOperation.m @@ -1,17 +1,17 @@ // AFXMLRequestOperation.m // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -29,7 +29,7 @@ static dispatch_queue_t xml_request_operation_processing_queue() { if (af_xml_request_operation_processing_queue == NULL) { af_xml_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.xml-request.processing", 0); } - + return af_xml_request_operation_processing_queue; } @@ -62,7 +62,7 @@ + (instancetype)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest failure(operation.request, operation.response, error, [(AFXMLRequestOperation *)operation responseXMLParser]); } }]; - + return requestOperation; } @@ -74,7 +74,7 @@ + (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlReques AFXMLRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, __unused id responseObject) { if (success) { - NSXMLDocument *XMLDocument = [(AFXMLRequestOperation *)operation responseXMLDocument]; + NSXMLDocument *XMLDocument = [(AFXMLRequestOperation *)operation responseXMLDocument]; success(operation.request, operation.response, XMLDocument); } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { @@ -83,7 +83,7 @@ + (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlReques failure(operation.request, operation.response, error, XMLDocument); } }]; - + return requestOperation; } #endif @@ -93,7 +93,7 @@ - (NSXMLParser *)responseXMLParser { if (!_responseXMLParser && [self.responseData length] > 0 && [self isFinished]) { self.responseXMLParser = [[NSXMLParser alloc] initWithData:self.responseData]; } - + return _responseXMLParser; } @@ -104,7 +104,7 @@ - (NSXMLDocument *)responseXMLDocument { self.responseXMLDocument = [[NSXMLDocument alloc] initWithData:self.responseData options:0 error:&error]; self.XMLError = error; } - + return _responseXMLDocument; } #endif @@ -121,7 +121,7 @@ - (NSError *)error { - (void)cancel { [super cancel]; - + self.responseXMLParser.delegate = nil; } @@ -140,10 +140,10 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" - self.completionBlock = ^ { + self.completionBlock = ^ { dispatch_async(xml_request_operation_processing_queue(), ^(void) { NSXMLParser *XMLParser = self.responseXMLParser; - + if (self.error) { if (failure) { dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ @@ -155,7 +155,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ success(self, XMLParser); }); - } + } } }); }; diff --git a/AFNetworking/UIImageView+AFNetworking.h b/AFNetworking/UIImageView+AFNetworking.h index 6483b61232..f9a389f614 100644 --- a/AFNetworking/UIImageView+AFNetworking.h +++ b/AFNetworking/UIImageView+AFNetworking.h @@ -1,17 +1,17 @@ // UIImageView+AFNetworking.h // // Copyright (c) 2011 Gowalla (http://gowalla.com/) -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -35,36 +35,36 @@ /** Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL, and sets it the request is finished. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - + @discussion By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` - + @param url The URL used for the image request. */ - (void)setImageWithURL:(NSURL *)url; /** Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - + @param url The URL used for the image request. @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. - + @discussion By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` -*/ -- (void)setImageWithURL:(NSURL *)url + */ +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholderImage; /** Creates and enqueues an image request operation, which asynchronously downloads the image with the specified URL request object. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - + @param urlRequest The URL request used for the image request. @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. @param success A block to be executed when the image request operation finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the request and response parameters will be `nil`. @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. - + @discussion If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is executed. -*/ -- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest - placeholderImage:(UIImage *)placeholderImage + */ +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(UIImage *)placeholderImage success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; From b70be414b75721c8d11773813eed866ba5aff126 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Tue, 29 Jan 2013 15:31:12 +0000 Subject: [PATCH 0060/1434] Fixing @param name to correspond to actual parameter (filename -> fileName) --- AFNetworking/AFHTTPClient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 9c64687a07..d1c6f73368 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -554,7 +554,7 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; @param data The data to be encoded and appended to the form data. @param name The name to be associated with the specified data. This parameter must not be `nil`. - @param filename The filename to be associated with the specified data. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified data. This parameter must not be `nil`. @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. */ - (void)appendPartWithFileData:(NSData *)data From b5c48f13a1d42952da78ab3027b7d804048f525b Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Tue, 29 Jan 2013 15:31:16 +0000 Subject: [PATCH 0061/1434] Fixing warning caused by default statement in switch statement that covered all enumeration values --- AFNetworking/AFHTTPClient.m | 1 - 1 file changed, 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index a7b9569b3e..c13a52418b 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1241,7 +1241,6 @@ - (BOOL)transitionToNextPhase { _phase = AFFinalBoundaryPhase; break; case AFFinalBoundaryPhase: - default: _phase = AFEncapsulationBoundaryPhase; break; } From eac6ffbb6ef1fc16b27706bc848a5e6f5796125d Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 30 Jan 2013 16:25:56 +0000 Subject: [PATCH 0062/1434] Revert "Fixing warning caused by default statement in switch statement that covered all enumeration values" This reverts commit b5c48f13a1d42952da78ab3027b7d804048f525b. --- AFNetworking/AFHTTPClient.m | 1 + 1 file changed, 1 insertion(+) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index c13a52418b..a7b9569b3e 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1241,6 +1241,7 @@ - (BOOL)transitionToNextPhase { _phase = AFFinalBoundaryPhase; break; case AFFinalBoundaryPhase: + default: _phase = AFEncapsulationBoundaryPhase; break; } From 9ba48388628df9ac8ebe6cdd5475a0179cf908b2 Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Wed, 30 Jan 2013 10:26:01 -0600 Subject: [PATCH 0063/1434] Added in a property to handle invalid SSL certs --- AFNetworking/AFURLConnectionOperation.h | 5 +++++ AFNetworking/AFURLConnectionOperation.m | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index ff4130d4e4..c580840f6c 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -105,6 +105,11 @@ */ @property (readonly, nonatomic, strong) NSError *error; +/** + The flag to determine if the connection should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to YES. Otherwise, this property defaults to NO. + */ +@property (nonatomic,assign) BOOL allowInvalidSSLCertificate; + ///---------------------------- /// @name Getting Response Data ///---------------------------- diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 122ec36d12..99e16939c0 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -212,6 +212,11 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest { self.outputStream = [NSOutputStream outputStreamToMemory]; self.state = AFOperationReadyState; + + //This ifdef has been added for backwards compatibility purposes +#ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ + self.allowInvalidSSLCertificate = YES; +#endif return self; } @@ -521,11 +526,10 @@ - (void)connection:(NSURLConnection *)connection - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { -#ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ - if ([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { - return YES; + if(self.allowInvalidSSLCertificate && + [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + return YES; } -#endif if (self.authenticationAgainstProtectionSpace) { return self.authenticationAgainstProtectionSpace(connection, protectionSpace); @@ -539,12 +543,13 @@ - (BOOL)connection:(NSURLConnection *)connection - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { -#ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ - if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + + if(self.allowInvalidSSLCertificate + && [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; return; } -#endif + if (self.authenticationChallenge) { self.authenticationChallenge(connection, challenge); @@ -692,6 +697,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder { self.error = [aDecoder decodeObjectForKey:@"error"]; self.responseData = [aDecoder decodeObjectForKey:@"responseData"]; self.totalBytesRead = [[aDecoder decodeObjectForKey:@"totalBytesRead"] longLongValue]; + self.allowInvalidSSLCertificate = [[aDecoder decodeObjectForKey:@"allowInvalidSSLCertificate"] boolValue]; return self; } @@ -716,6 +722,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.error forKey:@"error"]; [aCoder encodeObject:self.responseData forKey:@"responseData"]; [aCoder encodeObject:[NSNumber numberWithLongLong:self.totalBytesRead] forKey:@"totalBytesRead"]; + [aCoder encodeObject:[NSNumber numberWithBool:self.allowInvalidSSLCertificate] forKey:@"allowInvalidSSLCertificate"]; } #pragma mark - NSCopying @@ -729,6 +736,7 @@ - (id)copyWithZone:(NSZone *)zone { operation.authenticationChallenge = self.authenticationChallenge; operation.cacheResponse = self.cacheResponse; operation.redirectResponse = self.redirectResponse; + operation.allowInvalidSSLCertificate = self.allowInvalidSSLCertificate; return operation; } From d998515d24e475c0697bc83f648db09b066ef802 Mon Sep 17 00:00:00 2001 From: flop Date: Wed, 30 Jan 2013 21:52:13 +0300 Subject: [PATCH 0064/1434] Fix [Issue #751] --- AFNetworking/AFURLConnectionOperation.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index ff4130d4e4..d300653b95 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -75,7 +75,14 @@ - 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 would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. */ -@interface AFURLConnectionOperation : NSOperation +@interface AFURLConnectionOperation : NSOperation = __IPHONE_5_0 +NSURLConnectionDataDelegate, +#endif +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8 +NSURLConnectionDataDelegate, +#endif +NSCoding, NSCopying> ///------------------------------- /// @name Accessing Run Loop Modes From 0dbff8387b0f2137bff9e868790a14ef9718eb25 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Wed, 30 Jan 2013 12:25:22 -0800 Subject: [PATCH 0065/1434] Serialize calls to responseJSON using a lock. AFJSONRequestOperation's completion path calls `responseJSON` from a processing queue. Because `responseJSON` "lazily" deserializes the response data into a JSON object, it needs to be protected against concurrent access from other queues (threads). For example, `AFNetworkingOperationDidFinishNotification` is posted when the operation finishes but perhaps before that processing queue has finishing executing. Notification observers who also access `responseJSON` end up in a race with that queue that often leads to a crash. We reuse the existing lock from our AFURLConnectionOperation base class. --- AFNetworking/AFJSONRequestOperation.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index bb893b5a06..c46a8f06bc 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -31,6 +31,10 @@ static dispatch_queue_t json_request_operation_processing_queue() { return af_json_request_operation_processing_queue; } +@interface AFURLConnectionOperation () +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; +@end + @interface AFJSONRequestOperation () @property (readwrite, nonatomic, strong) id responseJSON; @property (readwrite, nonatomic, strong) NSError *JSONError; @@ -61,6 +65,7 @@ + (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest - (id)responseJSON { + [self.lock lock]; if (!_responseJSON && [self.responseData length] > 0 && [self isFinished] && !self.JSONError) { NSError *error = nil; @@ -77,6 +82,7 @@ - (id)responseJSON { self.JSONError = error; } + [self.lock unlock]; return _responseJSON; } From 0f794ccfc95fcdc445f4c23f3440b0125aafaf8f Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 31 Jan 2013 06:54:45 +0000 Subject: [PATCH 0066/1434] [Issue #769] Resolving asymmetry in cached image case for UIImageView category --- AFNetworking/UIImageView+AFNetworking.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/AFNetworking/UIImageView+AFNetworking.m b/AFNetworking/UIImageView+AFNetworking.m index 2e8b9c1e2d..74bac53856 100644 --- a/AFNetworking/UIImageView+AFNetworking.m +++ b/AFNetworking/UIImageView+AFNetworking.m @@ -102,12 +102,13 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest UIImage *cachedImage = [[[self class] af_sharedImageCache] cachedImageForRequest:urlRequest]; if (cachedImage) { - self.image = cachedImage; - self.af_imageRequestOperation = nil; - if (success) { success(nil, nil, cachedImage); + } else { + self.image = cachedImage; } + + self.af_imageRequestOperation = nil; } else { self.image = placeholderImage; From c790135fd4b8ae4653119bdb8ac9fff9a9d2fd94 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 31 Jan 2013 06:55:04 +0000 Subject: [PATCH 0067/1434] Updating OS X project settings --- .../AFNetworking Mac Example.xcodeproj/project.pbxproj | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj b/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj index 59617d1404..c679d7236d 100644 --- a/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj +++ b/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj @@ -206,7 +206,7 @@ F8129BF21591061B009BFE23 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0450; + LastUpgradeCheck = 0460; }; buildConfigurationList = F8129BF51591061B009BFE23 /* Build configuration list for PBXProject "AFNetworking Mac Example" */; compatibilityVersion = "Xcode 3.2"; @@ -265,6 +265,10 @@ ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; @@ -292,6 +296,10 @@ ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_C_LANGUAGE_STANDARD = gnu99; From e969fcd90417d9ad67d45a838bdaf93481d219a3 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 31 Jan 2013 07:00:03 +0000 Subject: [PATCH 0068/1434] Cleaning up formatting from pull request Adding @dynamic for lock property --- AFNetworking/AFJSONRequestOperation.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index c46a8f06bc..a078e52878 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -31,19 +31,17 @@ static dispatch_queue_t json_request_operation_processing_queue() { return af_json_request_operation_processing_queue; } -@interface AFURLConnectionOperation () -@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; -@end - @interface AFJSONRequestOperation () @property (readwrite, nonatomic, strong) id responseJSON; @property (readwrite, nonatomic, strong) NSError *JSONError; +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; @end @implementation AFJSONRequestOperation @synthesize responseJSON = _responseJSON; @synthesize JSONReadingOptions = _JSONReadingOptions; @synthesize JSONError = _JSONError; +@dynamic lock; + (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success From be72f5fe1f4fe18abb4febce4ab8a92c8ee07e59 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 31 Jan 2013 07:06:26 +0000 Subject: [PATCH 0069/1434] [Issue #767] Consolidating macros --- AFNetworking/AFURLConnectionOperation.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index d300653b95..233627dc8e 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -76,11 +76,9 @@ - Operation copies do not include `completionBlock`. `completionBlock` often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. */ @interface AFURLConnectionOperation : NSOperation = __IPHONE_5_0 -NSURLConnectionDataDelegate, -#endif -#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8 -NSURLConnectionDataDelegate, +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8) +NSURLConnectionDataDelegate, #endif NSCoding, NSCopying> From 74da4493f2f8ec8739621ce6cacacd348869e27d Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 1 Feb 2013 02:39:02 +0000 Subject: [PATCH 0070/1434] Wrapping AFHTTPBodyPart switch statement with #pragma to ignore -Wcovered-switch-default --- AFNetworking/AFHTTPClient.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index a7b9569b3e..8795ae34ed 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1227,6 +1227,8 @@ - (BOOL)transitionToNextPhase { return YES; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" switch (_phase) { case AFEncapsulationBoundaryPhase: _phase = AFHeaderPhase; @@ -1246,6 +1248,7 @@ - (BOOL)transitionToNextPhase { break; } _phaseReadOffset = 0; +#pragma clang diagnostic pop return YES; } From 6b8cdf15819d1d7c7b8d7d21020bb283e9458c7c Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Wed, 30 Jan 2013 11:22:15 +1100 Subject: [PATCH 0071/1434] Fixes warning: multiple methods named 'postNotificationName:object:' found [-Wstrict-selector-match] --- AFNetworking/AFHTTPClient.m | 3 ++- AFNetworking/AFURLConnectionOperation.m | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 8795ae34ed..bf26305213 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -304,7 +304,8 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ } dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; }); } diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 122ec36d12..bb8bf55d2c 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -341,12 +341,13 @@ - (void)setState:(AFOperationState)state { [self.lock unlock]; dispatch_async(dispatch_get_main_queue(), ^{ + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; switch (state) { case AFOperationExecutingState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; + [notificationCenter postNotificationName:AFNetworkingOperationDidStartNotification object:self]; break; case AFOperationFinishedState: - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; break; default: break; @@ -393,7 +394,8 @@ - (void)pause { [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; }); } From 8558d4d5f0d21174e3c785efa47e53ae3a2c8b35 Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Wed, 30 Jan 2013 11:44:33 +1100 Subject: [PATCH 0072/1434] Fixes warning: multiple methods named 'objectForKey:' found [-Wstrict-selector-match] --- AFNetworking/AFHTTPClient.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index bf26305213..b9736e24b3 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -146,10 +146,11 @@ - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; if ([value isKindOfClass:[NSDictionary class]]) { + NSDictionary *dictionary = value; // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(caseInsensitiveCompare:)]; - [[[value allKeys] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]] enumerateObjectsUsingBlock:^(id nestedKey, __unused NSUInteger idx, __unused BOOL *stop) { - id nestedValue = [value objectForKey:nestedKey]; + [[[dictionary allKeys] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]] enumerateObjectsUsingBlock:^(id nestedKey, __unused NSUInteger idx, __unused BOOL *stop) { + id nestedValue = [dictionary objectForKey:nestedKey]; if (nestedValue) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; } From 22c7d4ec9637b2d56ee36b88330daee62751e56d Mon Sep 17 00:00:00 2001 From: Oliver Jones Date: Fri, 1 Feb 2013 02:45:13 +0000 Subject: [PATCH 0073/1434] Fixes warning: weak receiver may be unpredictably set to nil [-Wreceiver-is-weak] Signed-off-by: Mattt Thompson --- AFNetworking/AFHTTPClient.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index b9736e24b3..2ba4d23652 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -583,9 +583,10 @@ - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations for (AFHTTPRequestOperation *operation in operations) { AFCompletionBlock originalCompletionBlock = [operation.completionBlock copy]; - __weak AFHTTPRequestOperation *weakOperation = operation; + __weak __typeof(&*operation)weakOperation = operation; operation.completionBlock = ^{ - dispatch_queue_t queue = weakOperation.successCallbackQueue ?: dispatch_get_main_queue(); + __strong __typeof(&*weakOperation)strongOperation = weakOperation; + dispatch_queue_t queue = strongOperation.successCallbackQueue ?: dispatch_get_main_queue(); dispatch_group_async(dispatchGroup, queue, ^{ if (originalCompletionBlock) { originalCompletionBlock(); From 4b17ec6b51cc3e434f7cd4a2399f7543314e2dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Fri, 1 Feb 2013 12:23:26 +0100 Subject: [PATCH 0074/1434] Compare NSURLRequest rather than NSURL If you inadvertently load a nil URL in UIImageView+AFNetworking, the failure block of the image request operation is bypassed because [nil isEqual:nil] == NO. By comparing the URL request instead of the URL, the `isEqual:` test passes and the error is properly forwarded to the failure block parameter. --- AFNetworking/UIImageView+AFNetworking.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/UIImageView+AFNetworking.m b/AFNetworking/UIImageView+AFNetworking.m index 74bac53856..fd0e0711a8 100644 --- a/AFNetworking/UIImageView+AFNetworking.m +++ b/AFNetworking/UIImageView+AFNetworking.m @@ -114,7 +114,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { - if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) { + if ([urlRequest isEqual:[self.af_imageRequestOperation request]]) { if (success) { success(operation.request, operation.response, responseObject); } else { @@ -128,7 +128,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest [[[self class] af_sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { - if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) { + if ([urlRequest isEqual:[self.af_imageRequestOperation request]]) { if (failure) { failure(operation.request, operation.response, error); } From 9ae534b94f75ea047e5ca55faff2e5f4bddc91a4 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 1 Feb 2013 22:43:30 +0000 Subject: [PATCH 0075/1434] Limiting default Accept-Language header to 6 languages --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index f78780576a..7193c81f48 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -238,7 +238,7 @@ - (id)initWithBaseURL:(NSURL *)url { [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { float q = 1.0f - (idx * 0.1f); [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]]; - *stop = q <= 0.0f; + *stop = q <= 0.5f; }]; [self setDefaultHeader:@"Accept-Language" value:[acceptLanguagesComponents componentsJoinedByString:@", "]]; From 9b16005f4ea6fdbb0dc8767eca0c475a24636647 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Mon, 4 Feb 2013 00:00:25 +0100 Subject: [PATCH 0076/1434] Adding lock around AFHTTPRequestOperation -responseString --- AFNetworking/AFHTTPRequestOperation.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index d9cca8e770..f7601c0845 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -111,6 +111,7 @@ @interface AFHTTPRequestOperation () @property (readwrite, nonatomic, copy) NSString *HTTPResponseString; @property (readwrite, nonatomic, assign) long long totalContentLength; @property (readwrite, nonatomic, assign) long long offsetContentLength; +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; @end @implementation AFHTTPRequestOperation @@ -122,6 +123,7 @@ @implementation AFHTTPRequestOperation @synthesize offsetContentLength = _offsetContentLength; @dynamic request; @dynamic response; +@dynamic lock; - (void)dealloc { if (_successCallbackQueue) { @@ -170,6 +172,7 @@ - (NSError *)error { } - (NSString *)responseString { + [self.lock lock]; // When no explicit charset parameter is provided by the sender, media subtypes of the "text" type are defined to have a default charset value of "ISO-8859-1" when received via HTTP. Data in character sets other than "ISO-8859-1" or its subsets MUST be labeled with an appropriate charset value. // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.4.1 if (!self.HTTPResponseString && self.response && !self.response.textEncodingName && self.responseData) { @@ -180,6 +183,7 @@ - (NSString *)responseString { self.HTTPResponseString = [[NSString alloc] initWithData:self.responseData encoding:NSISOLatin1StringEncoding]; } } + [self.lock unlock]; if (self.HTTPResponseString) { return self.HTTPResponseString; From 447fb3a9139dfda864da81dcf08c3b47463b7795 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Mon, 4 Feb 2013 00:01:14 +0100 Subject: [PATCH 0077/1434] Adding lock around AFURLConnectionOperation -responseStringEncoding Adding check for self.response in AFURLConnectionOperation -responseStringEncoding --- AFNetworking/AFURLConnectionOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index bb8bf55d2c..1fc61db6f5 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -367,7 +367,7 @@ - (NSString *)responseString { - (NSStringEncoding)responseStringEncoding { [self.lock lock]; - if (!_responseStringEncoding) { + if (!_responseStringEncoding && self.response) { NSStringEncoding stringEncoding = NSUTF8StringEncoding; if (self.response.textEncodingName) { CFStringEncoding IANAEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName); From 321a2af79df41b647b8f4e6de48adc28e146349c Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Mon, 4 Feb 2013 00:20:56 +0100 Subject: [PATCH 0078/1434] Fixing warnings caused by implicit property attributes --- Example/Classes/Models/User.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Example/Classes/Models/User.h b/Example/Classes/Models/User.h index 99d973b882..20cd5de218 100644 --- a/Example/Classes/Models/User.h +++ b/Example/Classes/Models/User.h @@ -26,9 +26,9 @@ extern NSString * const kUserProfileImageDidLoadNotification; @interface User : NSObject -@property (readonly) NSUInteger userID; -@property (readonly) NSString *username; -@property (unsafe_unretained, readonly) NSURL *avatarImageURL; +@property (readonly, nonatomic) NSUInteger userID; +@property (readonly, nonatomic) NSString *username; +@property (readonly, nonatomic, unsafe_unretained) NSURL *avatarImageURL; - (id)initWithAttributes:(NSDictionary *)attributes; From fa3a77544f8331a5647b2c9b8d78063ba80a81f1 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Mon, 4 Feb 2013 00:21:42 +0100 Subject: [PATCH 0079/1434] Ignoring -Wcovered-switch-default in AFHTTPBodyPart -hasBytesAvailable --- AFNetworking/AFHTTPClient.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index dfdf4f9ed8..a48d73def3 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1165,6 +1165,8 @@ - (BOOL)hasBytesAvailable { return YES; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" switch (self.inputStream.streamStatus) { case NSStreamStatusNotOpen: case NSStreamStatusOpening: @@ -1178,6 +1180,8 @@ - (BOOL)hasBytesAvailable { default: return NO; } +#pragma clang diagnostic pop + } - (NSInteger)read:(uint8_t *)buffer From 87c8c776d9ab1fa3b7f459366430514a2e283863 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Mon, 4 Feb 2013 00:41:13 +0100 Subject: [PATCH 0080/1434] Using DISPATCH_QUEUE_CONCURRENT for all calls to dispatch_queue_create for media type processing queues --- AFNetworking/AFImageRequestOperation.m | 2 +- AFNetworking/AFJSONRequestOperation.m | 2 +- AFNetworking/AFPropertyListRequestOperation.m | 2 +- AFNetworking/AFXMLRequestOperation.m | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index e39c9d6f86..7fb166dc81 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -25,7 +25,7 @@ static dispatch_queue_t af_image_request_operation_processing_queue; static dispatch_queue_t image_request_operation_processing_queue() { if (af_image_request_operation_processing_queue == NULL) { - af_image_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.image-request.processing", 0); + af_image_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.image-request.processing", DISPATCH_QUEUE_CONCURRENT); } return af_image_request_operation_processing_queue; diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index a078e52878..3d713b73dd 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -25,7 +25,7 @@ static dispatch_queue_t af_json_request_operation_processing_queue; static dispatch_queue_t json_request_operation_processing_queue() { if (af_json_request_operation_processing_queue == NULL) { - af_json_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.json-request.processing", 0); + af_json_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.json-request.processing", DISPATCH_QUEUE_CONCURRENT); } return af_json_request_operation_processing_queue; diff --git a/AFNetworking/AFPropertyListRequestOperation.m b/AFNetworking/AFPropertyListRequestOperation.m index 38229ce8e4..d9612f707b 100644 --- a/AFNetworking/AFPropertyListRequestOperation.m +++ b/AFNetworking/AFPropertyListRequestOperation.m @@ -25,7 +25,7 @@ static dispatch_queue_t af_property_list_request_operation_processing_queue; static dispatch_queue_t property_list_request_operation_processing_queue() { if (af_property_list_request_operation_processing_queue == NULL) { - af_property_list_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.property-list-request.processing", 0); + af_property_list_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.property-list-request.processing", DISPATCH_QUEUE_CONCURRENT); } return af_property_list_request_operation_processing_queue; diff --git a/AFNetworking/AFXMLRequestOperation.m b/AFNetworking/AFXMLRequestOperation.m index 7e6b35266a..8ebd4eda67 100644 --- a/AFNetworking/AFXMLRequestOperation.m +++ b/AFNetworking/AFXMLRequestOperation.m @@ -27,7 +27,7 @@ static dispatch_queue_t af_xml_request_operation_processing_queue; static dispatch_queue_t xml_request_operation_processing_queue() { if (af_xml_request_operation_processing_queue == NULL) { - af_xml_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.xml-request.processing", 0); + af_xml_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.xml-request.processing", DISPATCH_QUEUE_CONCURRENT); } return af_xml_request_operation_processing_queue; From ba60cab1bef8dcb953f3d4d9ce27dfcb23d9fccc Mon Sep 17 00:00:00 2001 From: Sasmito Adibowo Date: Mon, 4 Feb 2013 00:45:35 +0100 Subject: [PATCH 0081/1434] Use dispatch_once to initialize content-type-specific processing queues Signed-off-by: Mattt Thompson --- AFNetworking/AFImageRequestOperation.m | 7 ++++--- AFNetworking/AFJSONRequestOperation.m | 7 ++++--- AFNetworking/AFPropertyListRequestOperation.m | 7 ++++--- AFNetworking/AFXMLRequestOperation.m | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index 7fb166dc81..0a0390f818 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -22,11 +22,12 @@ #import "AFImageRequestOperation.h" -static dispatch_queue_t af_image_request_operation_processing_queue; static dispatch_queue_t image_request_operation_processing_queue() { - if (af_image_request_operation_processing_queue == NULL) { + static dispatch_queue_t af_image_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ af_image_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.image-request.processing", DISPATCH_QUEUE_CONCURRENT); - } + }); return af_image_request_operation_processing_queue; } diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 3d713b73dd..008aaccbbb 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -22,11 +22,12 @@ #import "AFJSONRequestOperation.h" -static dispatch_queue_t af_json_request_operation_processing_queue; static dispatch_queue_t json_request_operation_processing_queue() { - if (af_json_request_operation_processing_queue == NULL) { + static dispatch_queue_t af_json_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ af_json_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.json-request.processing", DISPATCH_QUEUE_CONCURRENT); - } + }); return af_json_request_operation_processing_queue; } diff --git a/AFNetworking/AFPropertyListRequestOperation.m b/AFNetworking/AFPropertyListRequestOperation.m index d9612f707b..4d6123b56d 100644 --- a/AFNetworking/AFPropertyListRequestOperation.m +++ b/AFNetworking/AFPropertyListRequestOperation.m @@ -22,11 +22,12 @@ #import "AFPropertyListRequestOperation.h" -static dispatch_queue_t af_property_list_request_operation_processing_queue; static dispatch_queue_t property_list_request_operation_processing_queue() { - if (af_property_list_request_operation_processing_queue == NULL) { + static dispatch_queue_t af_property_list_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ af_property_list_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.property-list-request.processing", DISPATCH_QUEUE_CONCURRENT); - } + }); return af_property_list_request_operation_processing_queue; } diff --git a/AFNetworking/AFXMLRequestOperation.m b/AFNetworking/AFXMLRequestOperation.m index 8ebd4eda67..30a76b90ae 100644 --- a/AFNetworking/AFXMLRequestOperation.m +++ b/AFNetworking/AFXMLRequestOperation.m @@ -24,11 +24,12 @@ #include -static dispatch_queue_t af_xml_request_operation_processing_queue; static dispatch_queue_t xml_request_operation_processing_queue() { - if (af_xml_request_operation_processing_queue == NULL) { + static dispatch_queue_t af_xml_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ af_xml_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.xml-request.processing", DISPATCH_QUEUE_CONCURRENT); - } + }); return af_xml_request_operation_processing_queue; } From 5698ab3768b334bca0ebb5091634f89dc8e7a9b5 Mon Sep 17 00:00:00 2001 From: Nick Dawson Date: Tue, 5 Feb 2013 12:46:03 +0000 Subject: [PATCH 0082/1434] Added support for repeated key value pairs through use of NSSet --- AFNetworking/AFHTTPClient.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index a48d73def3..e2fd452509 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -160,6 +160,11 @@ - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding [array enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; }]; + } else if ([value isKindOfClass:[NSSet class]]) { + NSSet *set = value; + [set enumerateObjectsUsingBlock:^(id obj, BOOL *stop) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)]; + }]; } else { [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; } From b3625ebcd0ca889a52602b92e071aaf9253359f3 Mon Sep 17 00:00:00 2001 From: Steven Fisher Date: Thu, 7 Feb 2013 14:19:54 -0800 Subject: [PATCH 0083/1434] Fixed comment typo Minor typo. --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index e2fd452509..c990e13c8d 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1165,7 +1165,7 @@ - (unsigned long long)contentLength { } - (BOOL)hasBytesAvailable { - // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the avaiable buffer + // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the available buffer if (_phase == AFFinalBoundaryPhase) { return YES; } From 0e18f85bfb8ce731ff3d347e5b28a421f4cc6e5b Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 8 Feb 2013 14:21:52 +0100 Subject: [PATCH 0084/1434] Replacing #ifdef macro check for Security to _AFNETWORKING_PIN_SSL_CERTIFICATES_ --- AFNetworking/AFURLConnectionOperation.h | 4 ++-- AFNetworking/AFURLConnectionOperation.m | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index ef2a87ac17..16f815f8a9 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -76,7 +76,7 @@ - Operation copies do not include `completionBlock`. `completionBlock` often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. */ -#ifdef _SECURITY_SECBASE_H_ +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ typedef enum { AFSSLPinningModePublicKey, AFSSLPinningModeCertificate, @@ -162,7 +162,7 @@ NSCoding, NSCopying> /** The pinning mode which will be used for SSL connections. */ -#ifdef _SECURITY_SECBASE_H_ +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ @property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode SSLPinningMode; #endif diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index f4c7832cc1..e273498726 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -145,7 +145,7 @@ @implementation AFURLConnectionOperation @dynamic inputStream; @synthesize outputStream = _outputStream; @synthesize credential = _credential; -#ifdef _SECURITY_SECBASE_H_ +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ @synthesize SSLPinningMode = _SSLPinningMode; #endif @synthesize shouldUseCredentialStorage = _shouldUseCredentialStorage; @@ -178,7 +178,7 @@ + (NSThread *)networkRequestThread { return _networkRequestThread; } -#ifdef _SECURITY_SECBASE_H_ +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ + (NSArray *)pinnedCertificates { static NSArray *_pinnedCertificates = nil; static dispatch_once_t onceToken; @@ -535,7 +535,7 @@ - (void)cancelConnection { #pragma mark - NSURLConnectionDelegate -#ifdef _SECURITY_SECBASE_H_ +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { From 1053e00fff1fc8e03137f3d4a362330f7a989781 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 8 Feb 2013 14:22:27 +0100 Subject: [PATCH 0085/1434] Removing #warning about Security framework --- AFNetworking/AFURLConnectionOperation.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 16f815f8a9..c702f21dd8 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -81,8 +81,6 @@ typedef enum { AFSSLPinningModePublicKey, AFSSLPinningModeCertificate, } AFURLConnectionOperationSSLPinningMode; -#else -#warning Security framework not found in project, or not included in precompiled header. SSL Certificate Pinning functionality will not be available. #endif @interface AFURLConnectionOperation : NSOperation Date: Fri, 8 Feb 2013 14:37:17 +0100 Subject: [PATCH 0086/1434] Fixing compiler warnings in SSL pinning initializers Minor refactoring --- AFNetworking/AFURLConnectionOperation.m | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index e273498726..3d538e0861 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -186,11 +186,12 @@ + (NSArray *)pinnedCertificates { NSBundle *bundle = [NSBundle bundleForClass:[self class]]; NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; - NSMutableArray *certificates = [NSMutableArray array]; + NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]]; for (NSString *path in paths) { NSData *certificateData = [NSData dataWithContentsOfFile:path]; [certificates addObject:certificateData]; } + _pinnedCertificates = [[NSArray alloc] initWithArray:certificates]; }); @@ -202,25 +203,29 @@ + (NSArray *)pinnedPublicKeys { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ NSArray *pinnedCertificates = [self pinnedCertificates]; - NSMutableArray *publicKeys = [NSMutableArray array]; + NSMutableArray *publicKeys = [NSMutableArray arrayWithCapacity:[pinnedCertificates count]]; for (NSData *data in pinnedCertificates) { SecCertificateRef allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)data); - NSParameterAssert(allowedCertificate); + NSCParameterAssert(allowedCertificate); + + SecCertificateRef allowedCertificates[] = {allowedCertificate}; + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); SecPolicyRef policy = SecPolicyCreateBasicX509(); SecTrustRef allowedTrust = NULL; - OSStatus status = SecTrustCreateWithCertificates(allowedCertificate, policy, &allowedTrust); - NSAssert(status == noErr, @"SecTrustCreateWithCertificates error: %ld", status); + OSStatus status = SecTrustCreateWithCertificates(certificates, policy, &allowedTrust); + NSAssert(status == noErr, @"SecTrustCreateWithCertificates error: %ld", (long int)status); SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust); [publicKeys addObject:(__bridge_transfer id)allowedPublicKey]; - + CFRelease(allowedTrust); - CFRelease(allowedCertificate); CFRelease(policy); + CFRelease(certificates); + CFRelease(allowedCertificate); } - + _pinnedPublicKeys = [[NSArray alloc] initWithArray:publicKeys]; }); From 35c6f996c09f75e1534e09a923c8b03b3cc913f0 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 8 Feb 2013 14:38:49 +0100 Subject: [PATCH 0087/1434] Adding Security framework to example projects and adding #define for _AFNETWORKING_PIN_SSL_CERTIFICATES_ --- Example/AFNetworking Mac Example.xcodeproj/project.pbxproj | 4 ++++ Example/AFNetworking iOS Example.xcodeproj/project.pbxproj | 2 ++ Example/Prefix.pch | 2 ++ 3 files changed, 8 insertions(+) diff --git a/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj b/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj index c679d7236d..55a77a5659 100644 --- a/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj +++ b/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ F82EB080159A172000B10B56 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F82EB077159A172000B10B56 /* AFPropertyListRequestOperation.m */; }; F82EB081159A172000B10B56 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F82EB079159A172000B10B56 /* AFURLConnectionOperation.m */; }; F82EB082159A172000B10B56 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F82EB07B159A172000B10B56 /* AFXMLRequestOperation.m */; }; + F88812F216C533E9003C8B8C /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F88812F116C533E9003C8B8C /* Security.framework */; }; F8A847CF161F55A500940F39 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8A847CE161F55A500940F39 /* CoreServices.framework */; }; F8A847D2161F55AC00940F39 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8A847D1161F55AC00940F39 /* SystemConfiguration.framework */; }; /* End PBXBuildFile section */ @@ -57,6 +58,7 @@ F82EB07A159A172000B10B56 /* AFXMLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFXMLRequestOperation.h; path = ../AFNetworking/AFXMLRequestOperation.h; sourceTree = ""; }; F82EB07B159A172000B10B56 /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFXMLRequestOperation.m; path = ../AFNetworking/AFXMLRequestOperation.m; sourceTree = ""; }; F877018B159A1CE700B45C0D /* AFNetworking Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "AFNetworking Example.entitlements"; sourceTree = ""; }; + F88812F116C533E9003C8B8C /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; F8A847CE161F55A500940F39 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; F8A847D1161F55AC00940F39 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -66,6 +68,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F88812F216C533E9003C8B8C /* Security.framework in Frameworks */, F8A847D2161F55AC00940F39 /* SystemConfiguration.framework in Frameworks */, F8A847CF161F55A500940F39 /* CoreServices.framework in Frameworks */, F8129C001591061B009BFE23 /* Cocoa.framework in Frameworks */, @@ -78,6 +81,7 @@ F8129BF01591061B009BFE23 = { isa = PBXGroup; children = ( + F88812F116C533E9003C8B8C /* Security.framework */, F8A847D1161F55AC00940F39 /* SystemConfiguration.framework */, F8A847CE161F55A500940F39 /* CoreServices.framework */, F877018B159A1CE700B45C0D /* AFNetworking Example.entitlements */, diff --git a/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj b/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj index 16afe14725..64673152a1 100644 --- a/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj +++ b/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ F8129C7415910C37009BFE23 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C7215910C37009BFE23 /* AppDelegate.m */; }; F818101615E6A0C600EF93C2 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */; }; + F88812F016C533D6003C8B8C /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469E013957DF100DB05C8 /* Security.framework */; }; F8A847C1161F51A300940F39 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8A847C0161F51A300940F39 /* Default-568h@2x.png */; }; F8A847C3161F523E00940F39 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = F8A847C2161F523E00940F39 /* Default.png */; }; F8A847C5161F524200940F39 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8A847C4161F524200940F39 /* Default@2x.png */; }; @@ -95,6 +96,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F88812F016C533D6003C8B8C /* Security.framework in Frameworks */, F8E469651395739D00DB05C8 /* UIKit.framework in Frameworks */, F8E469671395739D00DB05C8 /* Foundation.framework in Frameworks */, F8E469691395739D00DB05C8 /* CoreGraphics.framework in Frameworks */, diff --git a/Example/Prefix.pch b/Example/Prefix.pch index 18b984d290..df78b3cab1 100644 --- a/Example/Prefix.pch +++ b/Example/Prefix.pch @@ -1,5 +1,7 @@ #import +#define _AFNETWORKING_PIN_SSL_CERTIFICATES_ + #if __IPHONE_OS_VERSION_MIN_REQUIRED #ifndef __IPHONE_3_0 #warning "This project uses features only available in iPhone SDK 3.0 and later." From d609df5321964ed99f7f0c1bf708810fc840a1b8 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 8 Feb 2013 15:08:26 +0100 Subject: [PATCH 0088/1434] Adding documentation about SSL Pinning --- AFNetworking/AFURLConnectionOperation.h | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index c702f21dd8..f8f9874277 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -59,6 +59,14 @@ The built-in `completionBlock` provided by `NSOperation` allows for custom behavior to be executed after the request finishes. It is a common pattern for class constructors in subclasses to take callback block parameters, and execute them conditionally in the body of its `completionBlock`. Make sure to handle cancelled operations appropriately when setting a `completionBlock` (i.e. returning early before parsing response data). See the implementation of any of the `AFHTTPRequestOperation` subclasses for an example of this. Subclasses are strongly discouraged from overriding `setCompletionBlock:`, as `AFURLConnectionOperation`'s implementation includes a workaround to mitigate retain cycles, and what Apple rather ominously refers to as ["The Deallocation Problem"](http://developer.apple.com/library/ios/#technotes/tn2109/). + + ## SSL Pinning + + Relying on the CA trust model to validate SSL certificates exposes your app to security vulnerabilities, such as man-in-the-middle attacks. For applications that connect to known servers, SSL certificate pinning provides an increased level of security, by checking server certificate validity against those specified in the app bundle. + + SSL with certificate pinning is strongly recommended for any application that transmits sensitive information to an external webservice. + + When `_AFNETWORKING_PIN_SSL_CERTIFICATES_` is defined and the Security framework is linked, connections will be validated on all matching certificates with a `.cer` extension in the bundle root. ## NSCoding & NSCopying Conformance @@ -158,7 +166,9 @@ NSCoding, NSCopying> @property (nonatomic, strong) NSURLCredential *credential; /** - The pinning mode which will be used for SSL connections. + The pinning mode which will be used for SSL connections. `AFSSLPinningModePublicKey` by default. + + @discussion To enable SSL Pinning, `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` in `Prefix.pch`. Also, make sure that the Security framework is linked with the binary. See the "SSL Pinning" section in the `AFURLConnectionOperation` header for more information. */ #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ @property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode SSLPinningMode; @@ -304,6 +314,21 @@ NSCoding, NSCopying> ///---------------- /** + ## Network Reachability + + The following constants are provided by `AFURLConnectionOperation` as possible SSL Pinning options. + + enum { + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, + } + + `AFSSLPinningModePublicKey` + Pin SSL connections to certificate public key (SPKI). + + `AFSSLPinningModeCertificate` + Pin SSL connections to exact certificate. This may cause problems when your certificate expires and needs re-issuance. + ## User info dictionary keys These keys may exist in the user info dictionary, in addition to those defined for NSError. From 8215c43680243097806250da2a88b396e3b3bf5f Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 8 Feb 2013 15:08:41 +0100 Subject: [PATCH 0089/1434] Minor reformatting of AFHTTPClient constants documentation --- AFNetworking/AFHTTPClient.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index bf8418f16f..1f58203f59 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -448,7 +448,7 @@ typedef enum { ///---------------- /** - ### Network Reachability + ## Network Reachability The following constants are provided by `AFHTTPClient` as possible network reachability statuses. @@ -479,7 +479,7 @@ typedef enum { A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. - ### Parameter Encoding + ## Parameter Encoding The following constants are provided by `AFHTTPClient` as possible methods for serializing parameters into query string or message body values. From effd1136d2100d5acb555f2144568d54708434fe Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Fri, 8 Feb 2013 15:11:06 +0100 Subject: [PATCH 0090/1434] Adding Security frameworks to podspec, and defining _AFNETWORKING_PIN_SSL_CERTIFICATES_ --- AFNetworking.podspec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/AFNetworking.podspec b/AFNetworking.podspec index 8c6affc7d0..b7e836b490 100644 --- a/AFNetworking.podspec +++ b/AFNetworking.podspec @@ -10,13 +10,16 @@ Pod::Spec.new do |s| s.requires_arc = true s.ios.deployment_target = '5.0' - s.ios.frameworks = 'MobileCoreServices', 'SystemConfiguration' + s.ios.frameworks = 'MobileCoreServices', 'SystemConfiguration', 'Security' s.osx.deployment_target = '10.7' - s.osx.frameworks = 'CoreServices', 'SystemConfiguration' + s.osx.frameworks = 'CoreServices', 'SystemConfiguration', 'Security' s.prefix_header_contents = <<-EOS #import + +#define _AFNETWORKING_PIN_SSL_CERTIFICATES_ + #if __IPHONE_OS_VERSION_MIN_REQUIRED #import #import From a563b61a347f7aa0ea7757fcc37f23ad77f1778d Mon Sep 17 00:00:00 2001 From: Zach Waugh Date: Sat, 9 Feb 2013 11:49:06 -0500 Subject: [PATCH 0091/1434] Ensure content type for path extension doesn't return null --- AFNetworking/AFHTTPClient.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index c990e13c8d..d74514310c 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -742,7 +742,12 @@ - (id)copyWithZone:(NSZone *)zone { static inline NSString * AFContentTypeForPathExtension(NSString *extension) { #ifdef __UTTYPE__ NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL); - return (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType); + NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType); + if (!contentType) { + return @"application/octet-stream"; + } else { + return contentType; + } #else return @"application/octet-stream"; #endif From caa9551ae422a01c53d890a219f620954b6f6764 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sat, 9 Feb 2013 19:36:37 +0100 Subject: [PATCH 0092/1434] [Issue #791] Matching operations on request URL path rather than absolute URL string --- AFNetworking/AFHTTPClient.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index e2fd452509..8f49be3d65 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -546,7 +546,7 @@ - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation { - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path { - NSString *URLStringToMatched = [[[self requestWithMethod:(method ?: @"GET") path:path parameters:nil] URL] absoluteString]; + NSString *pathToBeMatched = [[[self requestWithMethod:(method ?: @"GET") path:path parameters:nil] URL] path]; for (NSOperation *operation in [self.operationQueue operations]) { if (![operation isKindOfClass:[AFHTTPRequestOperation class]]) { @@ -554,9 +554,9 @@ - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method } BOOL hasMatchingMethod = !method || [method isEqualToString:[[(AFHTTPRequestOperation *)operation request] HTTPMethod]]; - BOOL hasMatchingURL = [[[[(AFHTTPRequestOperation *)operation request] URL] absoluteString] isEqualToString:URLStringToMatched]; + BOOL hasMatchingPath = [[[[(AFHTTPRequestOperation *)operation request] URL] path] isEqual:pathToBeMatched]; - if (hasMatchingMethod && hasMatchingURL) { + if (hasMatchingMethod && hasMatchingPath) { [operation cancel]; } } From 574792d9cbb7b0d8d330d92ae3aa97bc6072ddbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodri=CC=81guez=20Troitin=CC=83o?= Date: Fri, 15 Feb 2013 21:09:31 +0100 Subject: [PATCH 0093/1434] Fix documentation for appendPartWithFileURL:name:error:. The documentation said that the values for filename and the Content-Type header was being obtained from a NSURLResponse, but since this is a request, no response is available yet. The documentation has been changed to reflect better where those values really come from. --- AFNetworking/AFHTTPClient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index d1c6f73368..f2a63237df 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -543,7 +543,7 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; @return `YES` if the file data was successfully appended, otherwise `NO`. - @discussion The filename and MIME type for this data in the form will be automatically generated, using `NSURLResponse` `-suggestedFilename` and `-MIMEType`, respectively. + @discussion The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. */ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL name:(NSString *)name From 53abb542915a39df2500d5e02cd8bb99d941d118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodri=CC=81guez=20Troitin=CC=83o?= Date: Fri, 15 Feb 2013 21:13:09 +0100 Subject: [PATCH 0094/1434] Add method to allow custom file name and content type for multiparts. The previous method was selecting the file name and the MIME type automatically depending on the given file URL. The new method allows specifying a custom file name and a custom MIME type for the those parts. --- AFNetworking/AFHTTPClient.h | 17 +++++++++++++++++ AFNetworking/AFHTTPClient.m | 20 ++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index f2a63237df..eb6fb7cd17 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -549,6 +549,23 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; name:(NSString *)name error:(NSError * __autoreleasing *)error; +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`. + @param mimeType The declared MIME type of the file data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError *__autoreleasing *)error; + /** Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 3af22a23b6..e86fbe304a 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -819,6 +819,22 @@ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL NSParameterAssert(fileURL); NSParameterAssert(name); + NSString *fileName = [fileURL lastPathComponent]; + NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]); + return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error]; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + if (![fileURL isFileURL]) { NSDictionary *userInfo = [NSDictionary dictionaryWithObject:NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil) forKey:NSLocalizedFailureReasonErrorKey]; if (error != NULL) { @@ -836,8 +852,8 @@ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL } NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; - [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, [fileURL lastPathComponent]] forKey:@"Content-Disposition"]; - [mutableHeaders setValue:AFContentTypeForPathExtension([fileURL pathExtension]) forKey:@"Content-Type"]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; bodyPart.stringEncoding = self.stringEncoding; From 63e5f0b57ae124d94852c38294a8178c4a2d83ae Mon Sep 17 00:00:00 2001 From: Marc Nijdam Date: Tue, 19 Feb 2013 16:01:01 -0800 Subject: [PATCH 0095/1434] Adding comma (,) as a percent escaped character since it's in the reserved words per the RFC --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 3af22a23b6..f9d21668b6 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -81,7 +81,7 @@ } static NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { - static NSString * const kAFCharactersToBeEscaped = @":/?&=;+!@#$()~'"; + static NSString * const kAFCharactersToBeEscaped = @":/?&=;+!@#$()~',"; static NSString * const kAFCharactersToLeaveUnescaped = @"[]."; return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, (__bridge CFStringRef)kAFCharactersToLeaveUnescaped, (__bridge CFStringRef)kAFCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)); From 01b206071b547e599bc9bdb80fc1a7b1469f3bde Mon Sep 17 00:00:00 2001 From: Mike Ash Date: Thu, 21 Feb 2013 14:35:41 -0500 Subject: [PATCH 0096/1434] Reimplement AFMultipartBodyStream as AFMultipartBodyStreamProvider vending one side of a bound CFStream pair, to avoid subclassing NSInputStream and fix #781 --- AFNetworking/AFHTTPClient.m | 187 ++++++++++++++++++++---------------- 1 file changed, 105 insertions(+), 82 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 3af22a23b6..fec1c77757 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -773,7 +773,7 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length; @end -@interface AFMultipartBodyStream : NSInputStream +@interface AFMultipartBodyStreamProvider : NSObject @property (nonatomic, assign) NSUInteger numberOfBytesInPacket; @property (nonatomic, assign) NSTimeInterval delay; @property (nonatomic, readonly) unsigned long long contentLength; @@ -782,13 +782,15 @@ @interface AFMultipartBodyStream : NSInputStream - (id)initWithStringEncoding:(NSStringEncoding)encoding; - (void)setInitialAndFinalBoundaries; - (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart; + +- (NSInputStream *)inputStream; @end #pragma mark - @interface AFStreamingMultipartFormData () @property (readwrite, nonatomic, copy) NSMutableURLRequest *request; -@property (readwrite, nonatomic, strong) AFMultipartBodyStream *bodyStream; +@property (readwrite, nonatomic, strong) AFMultipartBodyStreamProvider *bodyStream; @property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; @end @@ -807,7 +809,7 @@ - (id)initWithURLRequest:(NSMutableURLRequest *)urlRequest self.request = urlRequest; self.stringEncoding = encoding; - self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding]; + self.bodyStream = [[AFMultipartBodyStreamProvider alloc] initWithStringEncoding:encoding]; return self; } @@ -910,7 +912,7 @@ - (NSMutableURLRequest *)requestByFinalizingMultipartFormData { [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", kAFMultipartFormBoundary] forHTTPHeaderField:@"Content-Type"]; [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"]; - [self.request setHTTPBodyStream:self.bodyStream]; + [self.request setHTTPBodyStream:self.bodyStream.inputStream]; return self.request; } @@ -919,7 +921,7 @@ - (NSMutableURLRequest *)requestByFinalizingMultipartFormData { #pragma mark - -@interface AFMultipartBodyStream () +@interface AFMultipartBodyStreamProvider () @property (nonatomic, assign) NSStreamStatus streamStatus; @property (nonatomic, strong) NSError *streamError; @@ -929,7 +931,15 @@ @interface AFMultipartBodyStream () @property (nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; @end -@implementation AFMultipartBodyStream +static const NSUInteger AFMultipartBodyStreamProviderBufferSize = 4096; + +@implementation AFMultipartBodyStreamProvider { + NSInputStream *_inputStream; + NSOutputStream *_outputStream; + NSMutableData *_buffer; + + id _keepalive; +} @synthesize streamStatus = _streamStatus; @synthesize streamError = _streamError; @synthesize stringEncoding = _stringEncoding; @@ -948,10 +958,16 @@ - (id)initWithStringEncoding:(NSStringEncoding)encoding { self.stringEncoding = encoding; self.HTTPBodyParts = [NSMutableArray array]; self.numberOfBytesInPacket = NSIntegerMax; - + + _buffer = [[NSMutableData alloc] init]; + return self; } +- (void)dealloc { + _outputStream.delegate = nil; +} + - (void)setInitialAndFinalBoundaries { if ([self.HTTPBodyParts count] > 0) { for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { @@ -968,80 +984,96 @@ - (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart { [self.HTTPBodyParts addObject:bodyPart]; } +- (NSInputStream *)inputStream { + if(_inputStream == nil) { + CFReadStreamRef readStream; + CFWriteStreamRef writeStream; + CFStreamCreateBoundPair(NULL, &readStream, &writeStream, AFMultipartBodyStreamProviderBufferSize); + _inputStream = CFBridgingRelease(readStream); + _outputStream = CFBridgingRelease(writeStream); + + _outputStream.delegate = self; + dispatch_sync(dispatch_get_main_queue(), ^{ + [_outputStream scheduleInRunLoop: [NSRunLoop currentRunLoop] forMode: NSDefaultRunLoopMode]; + }); + [_outputStream open]; + _keepalive = self; + //[self handleOutputStreamSpaceAvailable]; + } + + return _inputStream; +} + - (BOOL)isEmpty { return [self.HTTPBodyParts count] == 0; } -#pragma mark - NSInputStream +#pragma mark - NSStreamDelegate -- (NSInteger)read:(uint8_t *)buffer - maxLength:(NSUInteger)length -{ - if ([self streamStatus] == NSStreamStatusClosed) { - return 0; +- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode { + if(eventCode | NSStreamEventHasSpaceAvailable) { + [self handleOutputStreamSpaceAvailable]; } - NSInteger bytesRead = 0; +} - while ((NSUInteger)bytesRead < MIN(length, self.numberOfBytesInPacket)) { - if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) { - if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) { - break; +- (void)handleOutputStreamSpaceAvailable { + while([_outputStream hasSpaceAvailable]) { + if([_buffer length] > 0) { + NSInteger ret = [_outputStream write: [_buffer bytes] maxLength: [_buffer length]]; + if(ret < 0) { + /* I don't think an error should ever actually happen with a bound pair. + * If it does, we'll just close the stream and give up. */ + [self close]; + return; + } else { + /* Delete the written bytes from the buffer. */ + [_buffer replaceBytesInRange: NSMakeRange(0, ret) withBytes: NULL length: 0]; } } else { - bytesRead += [self.currentHTTPBodyPart read:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; - if (self.delay > 0.0f) { - [NSThread sleepForTimeInterval:self.delay]; + /* Refill the buffer. */ + + /* Make sure the current body part is valid. */ + if(self.currentHTTPBodyPart == nil) { + if(self.HTTPBodyPartEnumerator == nil) { + self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; + } + self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject]; + } + + /* If the current part is still nil, then it's the end of the road: close the stream and bail. */ + if(self.currentHTTPBodyPart == nil) { + [self close]; + return; } + + /* Read some data. */ + [_buffer setLength: AFMultipartBodyStreamProviderBufferSize]; + NSInteger ret = [self.currentHTTPBodyPart read: [_buffer mutableBytes] maxLength: [_buffer length]]; + if(ret < 0) { + /* Not sure how to handle an error currently. Close the output stream and bail out. */ + [self close]; + return; + } + + /* Resize the buffer to how much was actually read. */ + [_buffer setLength: ret]; + + /* If we hit EOF, invalidate the current body part so the next pass through will find a new one. */ + if(ret == 0) { + self.currentHTTPBodyPart = nil; + } + + /* Fall off the end. The next loop through will get data out of the buffer. */ } } - return bytesRead; -} - -- (BOOL)getBuffer:(__unused uint8_t **)buffer - length:(__unused NSUInteger *)len -{ - return NO; -} - -- (BOOL)hasBytesAvailable { - return [self streamStatus] == NSStreamStatusOpen; -} - -#pragma mark - NSStream - -- (void)open { - if (self.streamStatus == NSStreamStatusOpen) { - return; - } - - self.streamStatus = NSStreamStatusOpen; - - [self setInitialAndFinalBoundaries]; - self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; } - (void)close { - self.streamStatus = NSStreamStatusClosed; -} - -- (id)propertyForKey:(__unused NSString *)key { - return nil; -} - -- (BOOL)setProperty:(__unused id)property - forKey:(__unused NSString *)key -{ - return NO; + [_outputStream close]; + _outputStream.delegate = nil; + _keepalive = nil; } -- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop - forMode:(__unused NSString *)mode -{} - -- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop - forMode:(__unused NSString *)mode -{} - - (unsigned long long)contentLength { unsigned long long length = 0; for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { @@ -1051,26 +1083,10 @@ - (unsigned long long)contentLength { return length; } -#pragma mark - Undocumented CFReadStream Bridged Methods - -- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop - forMode:(__unused CFStringRef)aMode -{} - -- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop - forMode:(__unused CFStringRef)aMode -{} - -- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags - callback:(__unused CFReadStreamClientCallBack)inCallback - context:(__unused CFStreamClientContext *)inContext { - return NO; -} - #pragma mark - NSCopying -(id)copyWithZone:(NSZone *)zone { - AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; + AFMultipartBodyStreamProvider *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]]; @@ -1086,10 +1102,12 @@ -(id)copyWithZone:(NSZone *)zone { #pragma mark - typedef enum { + AFInitialPhase = 0, AFEncapsulationBoundaryPhase = 1, AFHeaderPhase = 2, AFBodyPhase = 3, AFFinalBoundaryPhase = 4, + AFCompletedPhase = 5, } AFHTTPBodyPartReadPhase; @interface AFHTTPBodyPart () { @@ -1118,6 +1136,7 @@ - (id)init { return nil; } + _phase = AFInitialPhase; [self transitionToNextPhase]; return self; @@ -1252,6 +1271,9 @@ - (BOOL)transitionToNextPhase { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wcovered-switch-default" switch (_phase) { + case AFInitialPhase: + _phase = AFEncapsulationBoundaryPhase; + break; case AFEncapsulationBoundaryPhase: _phase = AFHeaderPhase; break; @@ -1265,8 +1287,9 @@ - (BOOL)transitionToNextPhase { _phase = AFFinalBoundaryPhase; break; case AFFinalBoundaryPhase: + case AFCompletedPhase: default: - _phase = AFEncapsulationBoundaryPhase; + _phase = AFCompletedPhase; break; } _phaseReadOffset = 0; From 1e0bce2ba92ae8b468ea775e614a8bb1240dc3f3 Mon Sep 17 00:00:00 2001 From: Mike Ash Date: Thu, 21 Feb 2013 15:01:20 -0500 Subject: [PATCH 0097/1434] Delete useless commented-out call to handleOutputStreamSpaceAvailable, and fix the stream:handleEvent: bit flag check --- AFNetworking/AFHTTPClient.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index fec1c77757..07e813d2a1 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -998,7 +998,6 @@ - (NSInputStream *)inputStream { }); [_outputStream open]; _keepalive = self; - //[self handleOutputStreamSpaceAvailable]; } return _inputStream; @@ -1011,7 +1010,7 @@ - (BOOL)isEmpty { #pragma mark - NSStreamDelegate - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode { - if(eventCode | NSStreamEventHasSpaceAvailable) { + if(eventCode & NSStreamEventHasSpaceAvailable) { [self handleOutputStreamSpaceAvailable]; } } From bea04f497883f8a93cfee31375becc4d4a7c5093 Mon Sep 17 00:00:00 2001 From: Mike Ash Date: Fri, 22 Feb 2013 17:36:57 -0500 Subject: [PATCH 0098/1434] Fix deadlock from trying to do a dispatch_sync on the main queue when already on the main thread --- AFNetworking/AFHTTPClient.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 07e813d2a1..58123bc2ec 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -993,9 +993,14 @@ - (NSInputStream *)inputStream { _outputStream = CFBridgingRelease(writeStream); _outputStream.delegate = self; - dispatch_sync(dispatch_get_main_queue(), ^{ + if([NSThread isMainThread]) { [_outputStream scheduleInRunLoop: [NSRunLoop currentRunLoop] forMode: NSDefaultRunLoopMode]; - }); + } + else { + dispatch_sync(dispatch_get_main_queue(), ^{ + [_outputStream scheduleInRunLoop: [NSRunLoop currentRunLoop] forMode: NSDefaultRunLoopMode]; + }); + } [_outputStream open]; _keepalive = self; } From 580c5476168284abe5e53590d9536e063edddb81 Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Tue, 26 Feb 2013 08:37:18 +0100 Subject: [PATCH 0099/1434] Fixes -[AFURLConnectionOperation totalBytesRead] threading issue. --- AFNetworking/AFURLConnectionOperation.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 1fc61db6f5..5503e68abc 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -628,18 +628,18 @@ - (void)connection:(NSURLConnection __unused *)connection - (void)connection:(NSURLConnection __unused *)connection didReceiveData:(NSData *)data { - self.totalBytesRead += [data length]; - if ([self.outputStream hasSpaceAvailable]) { const uint8_t *dataBuffer = (uint8_t *) [data bytes]; [self.outputStream write:&dataBuffer[0] maxLength:[data length]]; } - - if (self.downloadProgress) { - dispatch_async(dispatch_get_main_queue(), ^{ + + dispatch_async(dispatch_get_main_queue(), ^{ + self.totalBytesRead += [data length]; + + if (self.downloadProgress) { self.downloadProgress([data length], self.totalBytesRead, self.response.expectedContentLength); - }); - } + } + }); } - (void)connectionDidFinishLoading:(NSURLConnection __unused *)connection { From dbd5fc3220c9069274a8b8562818a8b429604ad1 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 27 Feb 2013 09:24:18 -0800 Subject: [PATCH 0100/1434] Adding missing #pragma clang diagnostic pop (/thanks @tewha) --- AFNetworking/AFHTTPRequestOperation.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index f7601c0845..b8bec28eac 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -30,7 +30,6 @@ #define AF_CAST_TO_BLOCK __bridge void * #endif -// We do a little bit of duck typing in this file which can trigger this warning. Turn it off for this source file. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wstrict-selector-match" @@ -371,3 +370,5 @@ - (void)connection:(__unused NSURLConnection *)connection } @end + +#pragma clang diagnostic pop From 7673c3e1d0ac85683c42262dab158055b7a45af1 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 27 Feb 2013 09:55:07 -0800 Subject: [PATCH 0101/1434] [Issue #817] Removing unused totalContentLength and offsetContentLength properties, and implementation of -connection:didReceiveResponse: --- AFNetworking/AFHTTPRequestOperation.m | 46 --------------------------- 1 file changed, 46 deletions(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index b8bec28eac..1adea2bb71 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -108,8 +108,6 @@ @interface AFHTTPRequestOperation () @property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; @property (readwrite, nonatomic, strong) NSError *HTTPError; @property (readwrite, nonatomic, copy) NSString *HTTPResponseString; -@property (readwrite, nonatomic, assign) long long totalContentLength; -@property (readwrite, nonatomic, assign) long long offsetContentLength; @property (readwrite, nonatomic, strong) NSRecursiveLock *lock; @end @@ -118,8 +116,6 @@ @implementation AFHTTPRequestOperation @synthesize HTTPResponseString = _HTTPResponseString; @synthesize successCallbackQueue = _successCallbackQueue; @synthesize failureCallbackQueue = _failureCallbackQueue; -@synthesize totalContentLength = _totalContentLength; -@synthesize offsetContentLength = _offsetContentLength; @dynamic request; @dynamic response; @dynamic lock; @@ -327,48 +323,6 @@ + (BOOL)canProcessRequest:(NSURLRequest *)request { return [[self acceptableContentTypes] intersectsSet:AFContentTypesFromHTTPHeader([request valueForHTTPHeaderField:@"Accept"])]; } -#pragma mark - NSURLConnectionDelegate - -- (void)connection:(__unused NSURLConnection *)connection -didReceiveResponse:(NSURLResponse *)response -{ - self.response = (NSHTTPURLResponse *)response; - - // Set Content-Range header if status code of response is 206 (Partial Content) - // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.7 - long long totalContentLength = self.response.expectedContentLength; - long long fileOffset = 0; - NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200; - if (statusCode == 206) { - NSString *contentRange = [self.response.allHeaderFields valueForKey:@"Content-Range"]; - if ([contentRange hasPrefix:@"bytes"]) { - NSArray *byteRanges = [contentRange componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" -/"]]; - if ([byteRanges count] == 4) { - fileOffset = [[byteRanges objectAtIndex:1] longLongValue]; - totalContentLength = [[byteRanges objectAtIndex:2] longLongValue] ?: -1; // if this is "*", it's converted to 0, but -1 is default. - } - } - } else { - if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) { - [self.outputStream setProperty:[NSNumber numberWithInteger:0] forKey:NSStreamFileCurrentOffsetKey]; - } else { - if ([[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length] > 0) { - self.outputStream = [NSOutputStream outputStreamToMemory]; - - NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; - for (NSString *runLoopMode in self.runLoopModes) { - [self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode]; - } - } - } - } - - self.offsetContentLength = MAX(fileOffset, 0); - self.totalContentLength = totalContentLength; - - [self.outputStream open]; -} - @end #pragma clang diagnostic pop From b42ea1fdb6cb9032e16ee1a798eebcbf202ec0b2 Mon Sep 17 00:00:00 2001 From: Sean Kovacs Date: Wed, 27 Feb 2013 11:11:49 -0800 Subject: [PATCH 0102/1434] [Issue #803] Only set image in UIImageView category if non-nil Signed-off-by: Mattt Thompson --- AFNetworking/UIImageView+AFNetworking.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/UIImageView+AFNetworking.m b/AFNetworking/UIImageView+AFNetworking.m index fd0e0711a8..8e7f4b7bbf 100644 --- a/AFNetworking/UIImageView+AFNetworking.m +++ b/AFNetworking/UIImageView+AFNetworking.m @@ -117,7 +117,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest if ([urlRequest isEqual:[self.af_imageRequestOperation request]]) { if (success) { success(operation.request, operation.response, responseObject); - } else { + } else if (responseObject) { self.image = responseObject; } From 61188e2dad22d235a7c684312a07e5ef4f8ab77a Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Tue, 5 Mar 2013 14:42:23 -0800 Subject: [PATCH 0103/1434] [Issue #837] Refactoring implementation of HTTP string encoding edge case to -responseStringEncoding to fix potential inconsistency in effective value --- AFNetworking/AFHTTPRequestOperation.m | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 1adea2bb71..98aa07cd1f 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -107,18 +107,14 @@ @interface AFHTTPRequestOperation () @property (readwrite, nonatomic, strong) NSURLRequest *request; @property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; @property (readwrite, nonatomic, strong) NSError *HTTPError; -@property (readwrite, nonatomic, copy) NSString *HTTPResponseString; -@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; @end @implementation AFHTTPRequestOperation @synthesize HTTPError = _HTTPError; -@synthesize HTTPResponseString = _HTTPResponseString; @synthesize successCallbackQueue = _successCallbackQueue; @synthesize failureCallbackQueue = _failureCallbackQueue; @dynamic request; @dynamic response; -@dynamic lock; - (void)dealloc { if (_successCallbackQueue) { @@ -166,25 +162,19 @@ - (NSError *)error { } } -- (NSString *)responseString { - [self.lock lock]; +- (NSStringEncoding)responseStringEncoding { // When no explicit charset parameter is provided by the sender, media subtypes of the "text" type are defined to have a default charset value of "ISO-8859-1" when received via HTTP. Data in character sets other than "ISO-8859-1" or its subsets MUST be labeled with an appropriate charset value. // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.4.1 - if (!self.HTTPResponseString && self.response && !self.response.textEncodingName && self.responseData) { + if (self.response && !self.response.textEncodingName && self.responseData) { NSString *type = nil; AFGetMediaTypeAndSubtypeWithString([[self.response allHeaderFields] valueForKey:@"Content-Type"], &type, nil); if ([type isEqualToString:@"text"]) { - self.HTTPResponseString = [[NSString alloc] initWithData:self.responseData encoding:NSISOLatin1StringEncoding]; + return NSISOLatin1StringEncoding; } } - [self.lock unlock]; - if (self.HTTPResponseString) { - return self.HTTPResponseString; - } else { - return [super responseString]; - } + return [super responseStringEncoding]; } - (void)pause { From db305db733da040974c12f5fc6653db4388ac230 Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Wed, 6 Mar 2013 21:40:56 -0500 Subject: [PATCH 0104/1434] Rework delivery of AFNetworkingOperationDidStartNotification and AFNetworkingOperationDidFinishNotification to avoid crashes when logging in response to notifications --- AFNetworking/AFURLConnectionOperation.m | 34 +++++++++++-------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 5503e68abc..f4196ce723 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -339,20 +339,6 @@ - (void)setState:(AFOperationState)state { [self didChangeValueForKey:oldStateKey]; [self didChangeValueForKey:newStateKey]; [self.lock unlock]; - - dispatch_async(dispatch_get_main_queue(), ^{ - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - switch (state) { - case AFOperationExecutingState: - [notificationCenter postNotificationName:AFNetworkingOperationDidStartNotification object:self]; - break; - case AFOperationFinishedState: - [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; - break; - default: - break; - } - }); } - (NSString *)responseString { @@ -450,24 +436,34 @@ - (void)start { - (void)operationDidStart { [self.lock lock]; - if ([self isCancelled]) { - [self finish]; - } else { + if (! [self isCancelled]) { self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO]; - + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; for (NSString *runLoopMode in self.runLoopModes) { [self.connection scheduleInRunLoop:runLoop forMode:runLoopMode]; [self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode]; } - + [self.connection start]; } [self.lock unlock]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; + }); + + if ([self isCancelled]) { + [self finish]; + } } - (void)finish { self.state = AFOperationFinishedState; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + }); } - (void)cancel { From 95b4f6c97977ed463d0d145806028e16d1a0f66e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Thu, 7 Mar 2013 12:53:47 +0100 Subject: [PATCH 0105/1434] Set indentation settings to four spaces at the project level --- Example/AFNetworking Mac Example.xcodeproj/project.pbxproj | 3 +++ Example/AFNetworking iOS Example.xcodeproj/project.pbxproj | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj b/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj index c679d7236d..7b6a013b88 100644 --- a/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj +++ b/Example/AFNetworking Mac Example.xcodeproj/project.pbxproj @@ -86,7 +86,10 @@ F8129BFE1591061B009BFE23 /* Frameworks */, F8129BFC1591061B009BFE23 /* Products */, ); + indentWidth = 4; sourceTree = ""; + tabWidth = 4; + usesTabs = 0; }; F8129BFC1591061B009BFE23 /* Products */ = { isa = PBXGroup; diff --git a/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj b/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj index 16afe14725..37fcb1702f 100644 --- a/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj +++ b/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj @@ -152,7 +152,10 @@ F8E469631395739D00DB05C8 /* Frameworks */, F8E469611395739C00DB05C8 /* Products */, ); + indentWidth = 4; sourceTree = ""; + tabWidth = 4; + usesTabs = 0; }; F8E469611395739C00DB05C8 /* Products */ = { isa = PBXGroup; From 9c3530060c5619dc93abd872206c15ee3de41771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Thu, 7 Mar 2013 13:07:53 +0100 Subject: [PATCH 0106/1434] Update network activity indicator only if requests have a non nil URL --- .../AFNetworkActivityIndicatorManager.m | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.m b/AFNetworking/AFNetworkActivityIndicatorManager.m index 5b9ec822f1..b7e4256ff8 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.m +++ b/AFNetworking/AFNetworkActivityIndicatorManager.m @@ -62,8 +62,8 @@ - (id)init { return nil; } - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(incrementActivityCount) name:AFNetworkingOperationDidStartNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(decrementActivityCount) name:AFNetworkingOperationDidFinishNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkingOperationDidStart:) name:AFNetworkingOperationDidStartNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkingOperationDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil]; return self; } @@ -126,6 +126,20 @@ - (void)decrementActivityCount { [self updateNetworkActivityIndicatorVisibilityDelayed]; } +- (void)networkingOperationDidStart:(NSNotification *)notification { + AFURLConnectionOperation *connectionOperation = [notification object]; + if (connectionOperation.request.URL) { + [self incrementActivityCount]; + } +} + +- (void)networkingOperationDidFinish:(NSNotification *)notification { + AFURLConnectionOperation *connectionOperation = [notification object]; + if (connectionOperation.request.URL) { + [self decrementActivityCount]; + } +} + @end #endif From 953b8623d8b8dab095819dc89126d922330b12fd Mon Sep 17 00:00:00 2001 From: Garrett Murray Date: Thu, 7 Mar 2013 20:42:16 -0800 Subject: [PATCH 0107/1434] Add asterisk (*) as a percent escaped character since it's in the reserved words per the RFC --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index f9d21668b6..fbcee09f5e 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -81,7 +81,7 @@ } static NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { - static NSString * const kAFCharactersToBeEscaped = @":/?&=;+!@#$()~',"; + static NSString * const kAFCharactersToBeEscaped = @":/?&=;+!@#$()~',*"; static NSString * const kAFCharactersToLeaveUnescaped = @"[]."; return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, (__bridge CFStringRef)kAFCharactersToLeaveUnescaped, (__bridge CFStringRef)kAFCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)); From 6a46815eafdb3e8b5f46f94502756cd9b226d7ef Mon Sep 17 00:00:00 2001 From: Joel Parsons Date: Mon, 11 Mar 2013 13:15:19 +0000 Subject: [PATCH 0108/1434] The documentations states registered operation classes are consulted to the reverse order in which they are registered. New registrations are added to the beginning of the array in the register implementation. Fixed using the reverseObjectEnumerator when iterating the array which produced the opposite of documented behaviour. fixes #794 --- AFNetworking/AFHTTPClient.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index f9d21668b6..d4bba2f80a 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -517,12 +517,12 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure { AFHTTPRequestOperation *operation = nil; - NSString *className = nil; - NSEnumerator *enumerator = [self.registeredHTTPOperationClassNames reverseObjectEnumerator]; - while (!operation && (className = [enumerator nextObject])) { + + for (NSString * className in self.registeredHTTPOperationClassNames) { Class op_class = NSClassFromString(className); if (op_class && [op_class canProcessRequest:urlRequest]) { operation = [(AFHTTPRequestOperation *)[op_class alloc] initWithRequest:urlRequest]; + break; } } From 1bd7faf9644337905b217506158a6e95166634e8 Mon Sep 17 00:00:00 2001 From: Joel Parsons Date: Tue, 12 Mar 2013 10:47:45 +0000 Subject: [PATCH 0109/1434] changed op_class variable to more objective-c style variable name operationClass --- AFNetworking/AFHTTPClient.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index d4bba2f80a..d25039789b 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -519,9 +519,9 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR AFHTTPRequestOperation *operation = nil; for (NSString * className in self.registeredHTTPOperationClassNames) { - Class op_class = NSClassFromString(className); - if (op_class && [op_class canProcessRequest:urlRequest]) { - operation = [(AFHTTPRequestOperation *)[op_class alloc] initWithRequest:urlRequest]; + Class operationClass = NSClassFromString(className); + if (operationClass && [operationClass canProcessRequest:urlRequest]) { + operation = [(AFHTTPRequestOperation *)[operationClass alloc] initWithRequest:urlRequest]; break; } } From f9a0cbff3f8fff6c4a4dcc0145dd3af59bece9ff Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 14 Mar 2013 12:46:16 -0700 Subject: [PATCH 0110/1434] Minor formatting fix --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 9c7fc48792..be0de71ecd 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -518,7 +518,7 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR { AFHTTPRequestOperation *operation = nil; - for (NSString * className in self.registeredHTTPOperationClassNames) { + for (NSString *className in self.registeredHTTPOperationClassNames) { Class operationClass = NSClassFromString(className); if (operationClass && [operationClass canProcessRequest:urlRequest]) { operation = [(AFHTTPRequestOperation *)[operationClass alloc] initWithRequest:urlRequest]; From 167aeb1be0364f6b49e55093216fb90d7100d878 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 14 Mar 2013 12:48:05 -0700 Subject: [PATCH 0111/1434] Minor formatting fixes --- AFNetworking/AFHTTPClient.h | 2 +- AFNetworking/AFHTTPClient.m | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index eb6fb7cd17..bbf575d08d 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -564,7 +564,7 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; name:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType - error:(NSError *__autoreleasing *)error; + error:(NSError * __autoreleasing *)error; /** Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index be0de71ecd..bcd3a673a4 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -821,6 +821,7 @@ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL NSString *fileName = [fileURL lastPathComponent]; NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]); + return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error]; } @@ -828,7 +829,7 @@ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL name:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType - error:(NSError *__autoreleasing *)error + error:(NSError * __autoreleasing *)error { NSParameterAssert(fileURL); NSParameterAssert(name); From 29c87a3c92433bf82bfeb7c7ca4fd8e0ac0360d4 Mon Sep 17 00:00:00 2001 From: Konstantinos Vaggelakos Date: Thu, 14 Mar 2013 12:56:38 -0700 Subject: [PATCH 0112/1434] UIImageView+AFNetworking not using setHTTPShouldHandleCookies Signed-off-by: Mattt Thompson --- AFNetworking/UIImageView+AFNetworking.m | 1 - 1 file changed, 1 deletion(-) diff --git a/AFNetworking/UIImageView+AFNetworking.m b/AFNetworking/UIImageView+AFNetworking.m index 8e7f4b7bbf..f3409970bf 100644 --- a/AFNetworking/UIImageView+AFNetworking.m +++ b/AFNetworking/UIImageView+AFNetworking.m @@ -87,7 +87,6 @@ - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholderImage { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - [request setHTTPShouldHandleCookies:NO]; [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; From ac30ff95448b8489607c9b35609f48756d4cb129 Mon Sep 17 00:00:00 2001 From: joein3d Date: Mon, 18 Mar 2013 17:02:41 -0400 Subject: [PATCH 0113/1434] Add ability to appendPartWithInputStream to AFMultipartFormData. --- AFNetworking/AFHTTPClient.h | 16 ++++++++++++++++ AFNetworking/AFHTTPClient.m | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index d1c6f73368..87caab4d1e 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -572,6 +572,7 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; - (void)appendPartWithFormData:(NSData *)data name:(NSString *)name; + /** Appends HTTP headers, followed by the encoded data and the multipart form boundary. @@ -581,6 +582,21 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; - (void)appendPartWithHeaders:(NSDictionary *)headers body:(NSData *)body; +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary. + + @param inputStream The input stream to be appended to the form data + @param name The name to be associated with the specified input stream. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`. + @param length The length of the specified input stream in bytes. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(unsigned long long)length + mimeType:(NSString *)mimeType; + /** Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index f9d21668b6..8b58a226f7 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -893,6 +893,31 @@ - (void)appendPartWithHeaders:(NSDictionary *)headers [self.bodyStream appendHTTPBodyPart:bodyPart]; } +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(unsigned long long)length + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.body = inputStream; + + bodyPart.bodyContentLength = length; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes delay:(NSTimeInterval)delay { @@ -1136,6 +1161,8 @@ - (NSInputStream *)inputStream { _inputStream = [NSInputStream inputStreamWithData:self.body]; } else if ([self.body isKindOfClass:[NSURL class]]) { _inputStream = [NSInputStream inputStreamWithURL:self.body]; + } else if ( [self.body isKindOfClass:[NSInputStream class]] ) { + _inputStream = self.body; } } From 1bfed80989d984b35b6fac6439a7a7c8294d58fc Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Fri, 8 Feb 2013 19:41:59 +0100 Subject: [PATCH 0114/1434] Adds `AFSSLPinningModeNone`. --- AFNetworking/AFURLConnectionOperation.h | 1 + AFNetworking/AFURLConnectionOperation.m | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index f8f9874277..f4c3b0eee9 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -86,6 +86,7 @@ #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ typedef enum { + AFSSLPinningModeNone, AFSSLPinningModePublicKey, AFSSLPinningModeCertificate, } AFURLConnectionOperationSSLPinningMode; diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 3d538e0861..24818de48f 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -579,6 +579,24 @@ - (void)connection:(NSURLConnection *)connection break; } + case AFSSLPinningModeNone: { +#ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; +#else + SecTrustResultType result = 0; + OSStatus status = SecTrustEvaluate(serverTrust, &result); + NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); + + if (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; + } +#endif + break; + } } } } From 8a642a26988486ef888a77c0459f52cea56584e4 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 00:57:04 -0400 Subject: [PATCH 0115/1434] Minor formatting and documentation edits --- AFNetworking/AFHTTPClient.h | 2 +- AFNetworking/AFURLConnectionOperation.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 1f58203f59..cecacedf6a 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -21,9 +21,9 @@ // THE SOFTWARE. #import +#import "AFURLConnectionOperation.h" #import -#import "AFURLConnectionOperation.h" /** `AFHTTPClient` captures the common patterns of communicating with an web application over HTTP. It encapsulates information like base URL, authorization credentials, and HTTP headers, and uses them to construct and manage the execution of HTTP request operations. diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index f4c3b0eee9..1a54a5c3a7 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -169,7 +169,7 @@ NSCoding, NSCopying> /** The pinning mode which will be used for SSL connections. `AFSSLPinningModePublicKey` by default. - @discussion To enable SSL Pinning, `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` in `Prefix.pch`. Also, make sure that the Security framework is linked with the binary. See the "SSL Pinning" section in the `AFURLConnectionOperation` header for more information. + @discussion To enable SSL Pinning, `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` in `Prefix.pch`. Also, make sure that the Security framework is linked with the binary. See the "SSL Pinning" section in the `AFURLConnectionOperation`" header for more information. */ #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ @property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode SSLPinningMode; From 327cc7cea3a85ff425da1082be5111302ff67473 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 01:23:38 -0400 Subject: [PATCH 0116/1434] Minor refactoring / reformatting after merge --- AFNetworking/AFHTTPClient.m | 91 ++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 51 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index e38ad818e7..452d4980da 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -943,30 +943,29 @@ - (NSMutableURLRequest *)requestByFinalizingMultipartFormData { #pragma mark - @interface AFMultipartBodyStreamProvider () -@property (nonatomic, assign) NSStreamStatus streamStatus; -@property (nonatomic, strong) NSError *streamError; - @property (nonatomic, assign) NSStringEncoding stringEncoding; @property (nonatomic, strong) NSMutableArray *HTTPBodyParts; @property (nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; @property (nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; +@property (nonatomic, strong) NSInputStream *inputStream; +@property (nonatomic, strong) NSOutputStream *outputStream; +@property (nonatomic, strong) NSMutableData *buffer; @end static const NSUInteger AFMultipartBodyStreamProviderBufferSize = 4096; @implementation AFMultipartBodyStreamProvider { - NSInputStream *_inputStream; - NSOutputStream *_outputStream; - NSMutableData *_buffer; - - id _keepalive; +@private + // Workaround for stream delegates being weakly referenced, but otherwise unowned + __strong id _self; } -@synthesize streamStatus = _streamStatus; -@synthesize streamError = _streamError; @synthesize stringEncoding = _stringEncoding; @synthesize HTTPBodyParts = _HTTPBodyParts; @synthesize HTTPBodyPartEnumerator = _HTTPBodyPartEnumerator; @synthesize currentHTTPBodyPart = _currentHTTPBodyPart; +@synthesize inputStream = _inputStream; +@synthesize outputStream = _outputStream; +@synthesize buffer = _buffer; @synthesize numberOfBytesInPacket = _numberOfBytesInPacket; @synthesize delay = _delay; @@ -980,7 +979,7 @@ - (id)initWithStringEncoding:(NSStringEncoding)encoding { self.HTTPBodyParts = [NSMutableArray array]; self.numberOfBytesInPacket = NSIntegerMax; - _buffer = [[NSMutableData alloc] init]; + self.buffer = [[NSMutableData alloc] init]; return self; } @@ -1006,7 +1005,7 @@ - (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart { } - (NSInputStream *)inputStream { - if(_inputStream == nil) { + if (_inputStream == nil) { CFReadStreamRef readStream; CFWriteStreamRef writeStream; CFStreamCreateBoundPair(NULL, &readStream, &writeStream, AFMultipartBodyStreamProviderBufferSize); @@ -1014,16 +1013,16 @@ - (NSInputStream *)inputStream { _outputStream = CFBridgingRelease(writeStream); _outputStream.delegate = self; - if([NSThread isMainThread]) { - [_outputStream scheduleInRunLoop: [NSRunLoop currentRunLoop] forMode: NSDefaultRunLoopMode]; - } - else { + if ([NSThread isMainThread]) { + [_outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + } else { dispatch_sync(dispatch_get_main_queue(), ^{ - [_outputStream scheduleInRunLoop: [NSRunLoop currentRunLoop] forMode: NSDefaultRunLoopMode]; + [_outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; }); } [_outputStream open]; - _keepalive = self; + + _self = self; } return _inputStream; @@ -1035,60 +1034,50 @@ - (BOOL)isEmpty { #pragma mark - NSStreamDelegate -- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode { - if(eventCode & NSStreamEventHasSpaceAvailable) { +- (void)stream:(NSStream *)stream + handleEvent:(NSStreamEvent)eventCode +{ + if (eventCode & NSStreamEventHasSpaceAvailable) { [self handleOutputStreamSpaceAvailable]; } } - (void)handleOutputStreamSpaceAvailable { - while([_outputStream hasSpaceAvailable]) { - if([_buffer length] > 0) { - NSInteger ret = [_outputStream write: [_buffer bytes] maxLength: [_buffer length]]; - if(ret < 0) { - /* I don't think an error should ever actually happen with a bound pair. - * If it does, we'll just close the stream and give up. */ + while ([_outputStream hasSpaceAvailable]) { + if ([_buffer length] > 0) { + NSInteger numberOfBytesWritten = [_outputStream write:[_buffer bytes] maxLength:[_buffer length]]; + if (numberOfBytesWritten < 0) { [self close]; return; - } else { - /* Delete the written bytes from the buffer. */ - [_buffer replaceBytesInRange: NSMakeRange(0, ret) withBytes: NULL length: 0]; } + + [_buffer replaceBytesInRange:NSMakeRange(0, numberOfBytesWritten) withBytes:NULL length:0]; } else { - /* Refill the buffer. */ - - /* Make sure the current body part is valid. */ - if(self.currentHTTPBodyPart == nil) { - if(self.HTTPBodyPartEnumerator == nil) { + if (!self.currentHTTPBodyPart) { + if (!self.HTTPBodyPartEnumerator) { self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; } self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject]; } - /* If the current part is still nil, then it's the end of the road: close the stream and bail. */ - if(self.currentHTTPBodyPart == nil) { + if (!self.currentHTTPBodyPart) { [self close]; return; } - /* Read some data. */ - [_buffer setLength: AFMultipartBodyStreamProviderBufferSize]; - NSInteger ret = [self.currentHTTPBodyPart read: [_buffer mutableBytes] maxLength: [_buffer length]]; - if(ret < 0) { - /* Not sure how to handle an error currently. Close the output stream and bail out. */ + [_buffer setLength:AFMultipartBodyStreamProviderBufferSize]; + + NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:[_buffer mutableBytes] maxLength:[_buffer length]]; + if (numberOfBytesRead < 0) { [self close]; return; } - /* Resize the buffer to how much was actually read. */ - [_buffer setLength: ret]; + [_buffer setLength:numberOfBytesRead]; - /* If we hit EOF, invalidate the current body part so the next pass through will find a new one. */ - if(ret == 0) { + if(numberOfBytesRead == 0) { self.currentHTTPBodyPart = nil; - } - - /* Fall off the end. The next loop through will get data out of the buffer. */ + } } } } @@ -1096,7 +1085,8 @@ - (void)handleOutputStreamSpaceAvailable { - (void)close { [_outputStream close]; _outputStream.delegate = nil; - _keepalive = nil; + + _self = nil; } - (unsigned long long)contentLength { @@ -1110,7 +1100,7 @@ - (unsigned long long)contentLength { #pragma mark - NSCopying --(id)copyWithZone:(NSZone *)zone { +- (id)copyWithZone:(NSZone *)zone { AFMultipartBodyStreamProvider *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { @@ -1161,7 +1151,6 @@ - (id)init { return nil; } - _phase = AFInitialPhase; [self transitionToNextPhase]; return self; From 48d05e215fc70dfbb5bb8af8696ebda3a370b253 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 01:30:46 -0400 Subject: [PATCH 0117/1434] Re-implementing throttling in stream provider architecture --- AFNetworking/AFHTTPClient.m | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 452d4980da..0dd6874525 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -778,7 +778,7 @@ - (NSInteger)read:(uint8_t *)buffer @end @interface AFMultipartBodyStreamProvider : NSObject -@property (nonatomic, assign) NSUInteger numberOfBytesInPacket; +@property (nonatomic, assign) NSUInteger bufferLength; @property (nonatomic, assign) NSTimeInterval delay; @property (nonatomic, readonly) unsigned long long contentLength; @property (nonatomic, readonly, getter = isEmpty) BOOL empty; @@ -919,7 +919,7 @@ - (void)appendPartWithHeaders:(NSDictionary *)headers - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes delay:(NSTimeInterval)delay { - self.bodyStream.numberOfBytesInPacket = numberOfBytes; + self.bodyStream.bufferLength = numberOfBytes; self.bodyStream.delay = delay; } @@ -952,7 +952,7 @@ @interface AFMultipartBodyStreamProvider () @property (nonatomic, strong) NSMutableData *buffer; @end -static const NSUInteger AFMultipartBodyStreamProviderBufferSize = 4096; +static const NSUInteger AFMultipartBodyStreamProviderDefaultBufferLength = 4096; @implementation AFMultipartBodyStreamProvider { @private @@ -966,7 +966,7 @@ @implementation AFMultipartBodyStreamProvider { @synthesize inputStream = _inputStream; @synthesize outputStream = _outputStream; @synthesize buffer = _buffer; -@synthesize numberOfBytesInPacket = _numberOfBytesInPacket; +@synthesize bufferLength = _numberOfBytesInPacket; @synthesize delay = _delay; - (id)initWithStringEncoding:(NSStringEncoding)encoding { @@ -977,9 +977,10 @@ - (id)initWithStringEncoding:(NSStringEncoding)encoding { self.stringEncoding = encoding; self.HTTPBodyParts = [NSMutableArray array]; - self.numberOfBytesInPacket = NSIntegerMax; + self.bufferLength = NSIntegerMax; self.buffer = [[NSMutableData alloc] init]; + self.bufferLength = AFMultipartBodyStreamProviderDefaultBufferLength; return self; } @@ -1008,7 +1009,7 @@ - (NSInputStream *)inputStream { if (_inputStream == nil) { CFReadStreamRef readStream; CFWriteStreamRef writeStream; - CFStreamCreateBoundPair(NULL, &readStream, &writeStream, AFMultipartBodyStreamProviderBufferSize); + CFStreamCreateBoundPair(NULL, &readStream, &writeStream, self.bufferLength); _inputStream = CFBridgingRelease(readStream); _outputStream = CFBridgingRelease(writeStream); @@ -1065,7 +1066,7 @@ - (void)handleOutputStreamSpaceAvailable { return; } - [_buffer setLength:AFMultipartBodyStreamProviderBufferSize]; + [_buffer setLength:self.bufferLength]; NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:[_buffer mutableBytes] maxLength:[_buffer length]]; if (numberOfBytesRead < 0) { @@ -1074,10 +1075,14 @@ - (void)handleOutputStreamSpaceAvailable { } [_buffer setLength:numberOfBytesRead]; - + if(numberOfBytesRead == 0) { self.currentHTTPBodyPart = nil; - } + } + + if (self.delay > 0.0f) { + [NSThread sleepForTimeInterval:self.delay]; + } } } } From 7211755d9cd8538b91296cdee2fe30e818d79712 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 01:42:29 -0400 Subject: [PATCH 0118/1434] Minor reformatting --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index fafe0d90a0..b915d6ff3c 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1199,7 +1199,7 @@ - (NSInputStream *)inputStream { _inputStream = [NSInputStream inputStreamWithData:self.body]; } else if ([self.body isKindOfClass:[NSURL class]]) { _inputStream = [NSInputStream inputStreamWithURL:self.body]; - } else if ( [self.body isKindOfClass:[NSInputStream class]] ) { + } else if ([self.body isKindOfClass:[NSInputStream class]]) { _inputStream = self.body; } } From edebae2de672c0651a1f964dbcd806a34a70f5b2 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 01:42:50 -0400 Subject: [PATCH 0119/1434] Replacing getter method definition with readonly property --- AFNetworking/AFHTTPClient.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index b915d6ff3c..d4c40426c7 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -780,14 +780,13 @@ - (NSInteger)read:(uint8_t *)buffer @interface AFMultipartBodyStreamProvider : NSObject @property (nonatomic, assign) NSUInteger bufferLength; @property (nonatomic, assign) NSTimeInterval delay; +@property (nonatomic, readonly) NSInputStream *inputStream; @property (nonatomic, readonly) unsigned long long contentLength; @property (nonatomic, readonly, getter = isEmpty) BOOL empty; - (id)initWithStringEncoding:(NSStringEncoding)encoding; - (void)setInitialAndFinalBoundaries; - (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart; - -- (NSInputStream *)inputStream; @end #pragma mark - From 45c05caaa9799a64c9d64988ad035f329dd5c5e0 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 02:09:08 -0400 Subject: [PATCH 0120/1434] Renaming defaultPinMode -> defaultPinningMode, to match AFURLConnectionOperation Moving setting of pinning mode to creation of operation rather than -enqueueHTTPRequestOperation --- AFNetworking/AFHTTPClient.h | 2 +- AFNetworking/AFHTTPClient.m | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 398bb109fc..4c27c93d06 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -142,7 +142,7 @@ typedef enum { Default SSL pinning mode for each `AFHTTPRequestOperation` which will be enqueued with `enqueueHTTPRequestOperation:`. */ #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ -@property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode defaultSSLPinMode; +@property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode defaultSSLPinningMode; #endif ///--------------------------------------------- diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index d4c40426c7..88ec1cb7be 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -533,6 +533,9 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR [operation setCompletionBlockWithSuccess:success failure:failure]; operation.credential = self.defaultCredential; +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ + operation.SSLPinningMode = self.defaultSSLPinningMode; +#endif return operation; } @@ -540,10 +543,6 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR #pragma mark - - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation { -#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ - operation.SSLPinningMode = self.defaultSSLPinMode; -#endif - [self.operationQueue addOperation:operation]; } From e8d55c8896150fa888257f45eb397f934697b922 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 02:09:39 -0400 Subject: [PATCH 0121/1434] Adding documentation for AFSSLPinningModeNone --- AFNetworking/AFURLConnectionOperation.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 1a54a5c3a7..b3a94db106 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -320,9 +320,13 @@ NSCoding, NSCopying> The following constants are provided by `AFURLConnectionOperation` as possible SSL Pinning options. enum { + AFSSLPinningModeNone, AFSSLPinningModePublicKey, AFSSLPinningModeCertificate, } + + `AFSSLPinningModeNone` + Do not pin SSL connections `AFSSLPinningModePublicKey` Pin SSL connections to certificate public key (SPKI). From 59039d6a8348c2591b1a6ecb0bfcb9b49f3036e8 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 02:13:37 -0400 Subject: [PATCH 0122/1434] Re-ordering AFHTTPClient multipart proxy methods --- AFNetworking/AFHTTPClient.h | 30 +++++++++++----------- AFNetworking/AFHTTPClient.m | 51 +++++++++++++++++++------------------ 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 4c27c93d06..5551f5d771 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -574,6 +574,21 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; mimeType:(NSString *)mimeType error:(NSError * __autoreleasing *)error; +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary. + + @param inputStream The input stream to be appended to the form data + @param name The name to be associated with the specified input stream. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`. + @param length The length of the specified input stream in bytes. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(unsigned long long)length + mimeType:(NSString *)mimeType; + /** Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. @@ -607,21 +622,6 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; - (void)appendPartWithHeaders:(NSDictionary *)headers body:(NSData *)body; -/** - Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary. - - @param inputStream The input stream to be appended to the form data - @param name The name to be associated with the specified input stream. This parameter must not be `nil`. - @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`. - @param length The length of the specified input stream in bytes. - @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. - */ -- (void)appendPartWithInputStream:(NSInputStream *)inputStream - name:(NSString *)name - fileName:(NSString *)fileName - length:(unsigned long long)length - mimeType:(NSString *)mimeType; - /** Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 88ec1cb7be..bd0cab2de8 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -873,6 +873,32 @@ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL return YES; } + +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(unsigned long long)length + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.body = inputStream; + + bodyPart.bodyContentLength = length; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + - (void)appendPartWithFileData:(NSData *)data name:(NSString *)name fileName:(NSString *)fileName @@ -914,31 +940,6 @@ - (void)appendPartWithHeaders:(NSDictionary *)headers [self.bodyStream appendHTTPBodyPart:bodyPart]; } -- (void)appendPartWithInputStream:(NSInputStream *)inputStream - name:(NSString *)name - fileName:(NSString *)fileName - length:(unsigned long long)length - mimeType:(NSString *)mimeType -{ - NSParameterAssert(name); - NSParameterAssert(fileName); - NSParameterAssert(mimeType); - - NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; - [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; - [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; - - - AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; - bodyPart.stringEncoding = self.stringEncoding; - bodyPart.headers = mutableHeaders; - bodyPart.body = inputStream; - - bodyPart.bodyContentLength = length; - - [self.bodyStream appendHTTPBodyPart:bodyPart]; -} - - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes delay:(NSTimeInterval)delay { From 90f84c7120dd786c302ce489ec894c10ffa429ca Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 02:22:28 -0400 Subject: [PATCH 0123/1434] Updating CHANGES to 1.2.0 release --- CHANGES | 203 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 135 insertions(+), 68 deletions(-) diff --git a/CHANGES b/CHANGES index 70f5a33340..0e3c9a1062 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,70 @@ += 1.2.0 (2013-03-24) + + * Add `SSLPinningMode` property to `AFHTTPClient` (Oliver Letterer, Kevin Harwood, Adam Becevello, Dustin Barker, Mattt Thompson) + + * Add single quote ("'"), comma (","), and asterix ("*") to escaped URL encoding characters (Eric Florenzano, Marc Nijdam, Garrett Murray) + + * Add `credential` property to `AFURLConnectionOperation` (Mattt Thompson) + + * Add `-setDefaultCredential:` to `AFHTTPClient` + + * Fix request stream exhaustion error on authentication challenges (Alex Burgel) + + * Add `shouldUseCredentialStorage` property to `AFURLConnectionOperation` (Mattt Thompson) + + * Add support for repeated key value pairs in `AFHTTPClient` URL query string (Nick Dawson) + + * Add `AFMultipartFormData - appendPartWithFileURL:name:fileName:mimeType:error` (Daniel Rodríguez Troitiño) + + * Add `AFMultipartFormData - appendPartWithInputStream:name:fileName:mimeType:` (@joein3d) + + * Change SSL pinning to be runtime property on `AFURLConnectionOperation` rather than defined by macro (Oliver Letterer) + + * Change `AFMultipartBodyStream` to `AFMultipartBodyStreamProvider`, vending one side of a bound CFStream pair rather than subclassing `NSInputStream` (Mike Ash) + + * Change default `Accept-Language` header in `AFHTTPClient` (@therigu, Mattt Thompson) + + * Change `AFHTTPClient` operation cancellation to be based on request URL path rather than absolute URL string (Mattt Thompson) + + * Change request operation subclass processing queues to use `DISPATCH_QUEUE_CONCURRENT` (Mattt Thompson) + + * Change `UIImageView+AFNetworking` to resolve asymmetry in cached image case between success block provided and not provided (@Eveets, Mattt Thompson) + + * Change `UIImageView+AFNetworking` to compare `NSURLRequest` instead of `NSURL` to determine if previous request was equivalent (Cédric Luthi) + + * Change `UIImageView+AFNetworking` to only set image if non-`nil` (Sean Kovacs) + + * Change indentation settings to four spaces at the project level (Cédric Luthi) + + * Change `AFNetworkActivityIndicatorManager` to only update if requests have a non-`nil` URL (Cédric Luthi) + + * Change `UIImageView+AFNetworking` to not do `setHTTPShouldHandleCookies` (Konstantinos Vaggelakos) + + * Fix implementation to use `NSURL` methods instead of `CFURL` functions where applicable (Cédric Luthi) + + * Fix race condition in `UIImageView+AFNetworking` (Peyman) + + * Fix `responseJSON`, `responseString`, and `responseStringEncoding` to be threadsafe (Jon Parise, Mattt Thompson) + + * Fix `AFContentTypeForPathExtension` to ensure non-`NULL` content return value (Zach Waugh) + + * Fix documentation for `appendPartWithFileURL:name:error:` + (Daniel Rodríguez Troitiño) + + * Fix request operation subclass processing queues to initialize with `dispatch_once` (Sasmito Adibowo) + + * Fix posting of `AFNetworkingOperationDidStartNotification` and `AFNetworkingOperationDidFinishNotification` to avoid crashes when logging in response to notifications (Blake Watters) + + * Fix ordering of registered operation consultation in `AFHTTPClient` (Joel Parsons) + + * Fix warning: multiple methods named 'postNotificationName:object:' found [-Wstrict-selector-match] (Oliver Jones) + + * Fix warning: multiple methods named 'objectForKey:' found [-Wstrict-selector-match] (Oliver Jones) + + * Fix warning: weak receiver may be unpredictably set to nil [-Wreceiver-is-weak] (Oliver Jones) + + * Fix missing #pragma clang diagnostic pop (Steven Fisher) + = 1.1.0 (2012-12-27) * Add optional SSL certificate pinning with `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` (Dustin Barker) @@ -18,9 +85,9 @@ * Change `AFHTTPRequestOperation -responseString` to follow guidelines from RFC 2616 regarding the use of string encoding when none is specified in the response (Jorge Bernal) - * Change AFHTTPClient parameter serialization dictionary keys with `caseInsensitiveCompare:` to ensure - deterministic ordering of query string parameters, which may otherwise - cause ambiguous representations of nested parameters (James Coleman, + * Change AFHTTPClient parameter serialization dictionary keys with `caseInsensitiveCompare:` to ensure + deterministic ordering of query string parameters, which may otherwise + cause ambiguous representations of nested parameters (James Coleman, Mattt Thompson) * Fix -Wstrict-selector-match warnings raised by Xcode 4.6DP3 (Jesse Collis, Cédric Luthi) @@ -48,19 +115,19 @@ * Fix __unused keywords for better Xcode indexing (Christian Rasmussen) * Fix warning: unused parameter 'x' [-Werror,-Wunused-parameter] (Oliver Jones) - + * Fix warning: property is assumed atomic by default [-Werror,-Wimplicit-atomic-properties] (Oliver Jones) - + * Fix warning: weak receiver may be unpredictably null in ARC mode [-Werror,-Wreceiver-is-weak] (Oliver Jones) - + * Fix warning: multiple methods named 'selector' found [-Werror,-Wstrict-selector-match] (Oliver Jones) - + * Fix warning: 'macro' is not defined, evaluates to 0 (Oliver Jones) - + * Fix warning: atomic by default property 'X' has a user (Oliver Jones)defined getter (property should be marked 'atomic' if this is intended) [-Werror, -Wcustom-atomic-properties] (Oliver Jones) - + * Fix warning: 'response' was marked unused but was used [-Werror,-Wused-but-marked-unused] (Oliver Jones) - + * Fix warning: enumeration value 'AFFinalBoundaryPhase' not explicitly handled in switch [-Werror,-Wswitch-enum] (Oliver Jones) = 1.0.1 / 2012-11-01 @@ -72,7 +139,7 @@ was not correctly calculated (Stan Chang Khin Boon) placeholderImage:success:failure`:, it is now the responsibility of the block to set the image of the image view (Mattt Thompson) - * Add `JSONReadingOptions` property to `AFJSONRequestOperation` (Jeremy + * Add `JSONReadingOptions` property to `AFJSONRequestOperation` (Jeremy Foo, Mattt Thompson) * Using __weak self / __strong self pattern to break retain cycles in @@ -80,10 +147,10 @@ block to set the image of the image view (Mattt Thompson) * Fix parameter encoding to leave period (`.`) unescaped (Diego Torres) - * Fixing last file component in multipart form part creation (Sylver - Bruneau) - - * Remove executable permission on AFHTTPClient source files (Andrew + * Fixing last file component in multipart form part creation (Sylver + Bruneau) + + * Remove executable permission on AFHTTPClient source files (Andrew Sardone) * Fix warning (error with -Werror) on implicit 64 to 32 conversion (Dan @@ -96,144 +163,144 @@ block to set the image of the image view (Mattt Thompson) = 1.0 / 2012-10-15 * AFNetworking now requires iOS 5 / Mac OSX 10.7 or higher (Mattt Thompson) - + * AFNetworking now uses Automatic Reference Counting (ARC) (Mattt Thompson) - * AFNetworking raises compiler warnings for missing features when -SystemConfiguration or CoreServices / MobileCoreServices frameworks are not -included in the project and imported in the precompiled headers (Mattt + * AFNetworking raises compiler warnings for missing features when +SystemConfiguration or CoreServices / MobileCoreServices frameworks are not +included in the project and imported in the precompiled headers (Mattt Thompson) - * AFNetworking now raises compiler error when not compiled with ARC (Steven + * AFNetworking now raises compiler error when not compiled with ARC (Steven Fisher) - * Add `NSCoding` and `NSCopying` protocol conformance to + * Add `NSCoding` and `NSCopying` protocol conformance to `AFURLConnectionOperation` and `AFHTTPClient` (Mattt Thompson) - * Add substantial improvements HTTP multipart streaming support, having -files streamed directly from disk and read sequentially from a custom input + * Add substantial improvements HTTP multipart streaming support, having +files streamed directly from disk and read sequentially from a custom input stream (Max Lansing, Stan Chang Khin Boon, Mattt Thompson) - - * Add `AFMultipartFormData -throttleBandwidthWithPacketSize:delay:` as + + * Add `AFMultipartFormData -throttleBandwidthWithPacketSize:delay:` as workaround to issues when uploading over 3G (Mattt Thompson) - * Add request and response to `userInfo` of errors returned from failing + * Add request and response to `userInfo` of errors returned from failing `AFHTTPRequestOperation` (Mattt Thompson) - * Add `userInfo` dictionary with current status in reachability changes + * Add `userInfo` dictionary with current status in reachability changes (Mattt Thompson) - * Add `Accept` header for image requests in `UIImageView` category (Bratley + * Add `Accept` header for image requests in `UIImageView` category (Bratley Lower) - * Add explicit declaration of `NSURLConnection` delegate methods so that + * Add explicit declaration of `NSURLConnection` delegate methods so that they can be overridden in subclasses (Mattt Thompson, Evan Grim) - * Add parameter validation to match conditions specified in documentation + * Add parameter validation to match conditions specified in documentation (Jason Brennan, Mattt Thompson) - * Add import to `UIKit` to avoid build errors from `UIDevice` references in + * Add import to `UIKit` to avoid build errors from `UIDevice` references in `User-Agent` default header (Blake Watters) * Remove `AFJSONUtilities` in favor of `NSJSONSerialization` (Mattt Thompson) - * Remove `extern` declaration of `AFURLEncodedStringFromStringWithEncoding` -function (`CFURLCreateStringByAddingPercentEscapes` should be used instead) + * Remove `extern` declaration of `AFURLEncodedStringFromStringWithEncoding` +function (`CFURLCreateStringByAddingPercentEscapes` should be used instead) (Mattt Thompson) - * Remove `setHTTPShouldHandleCookies:NO` from `AFHTTPClient` (@phamsonha, + * Remove `setHTTPShouldHandleCookies:NO` from `AFHTTPClient` (@phamsonha, Mattt Thompson) - - * Remove `dispatch_retain` / `dispatch_release` with ARC in iOS 6 (Benoit + + * Remove `dispatch_retain` / `dispatch_release` with ARC in iOS 6 (Benoit Bourdon) - + * Fix threading issue with `AFNetworkActivityIndicatorManager` (Eric Patey) - * Fix issue where `AFNetworkActivityIndicatorManager` count could become + * Fix issue where `AFNetworkActivityIndicatorManager` count could become negative (@ap4y) - * Fix properties to explicitly set options to suppress warnings (Wen-Hao + * Fix properties to explicitly set options to suppress warnings (Wen-Hao Lue, Mattt Thompson) - * Fix compiler warning caused by mismatched types in upload / download + * Fix compiler warning caused by mismatched types in upload / download progress blocks (Gareth du Plooy, tomas.a) - - * Fix weak / strong variable relationships in `completionBlock` (Peter + + * Fix weak / strong variable relationships in `completionBlock` (Peter Steinberger) - * Fix string formatting syntax warnings caused by type mismatch (David + * Fix string formatting syntax warnings caused by type mismatch (David Keegan, Steven Fisher, George Cox) - * Fix minor potential security vulnerability by explicitly using string + * Fix minor potential security vulnerability by explicitly using string format in NSError localizedDescription value in userInfo (Steven Fisher) - * Fix `AFURLConnectionOperation -pause` by adding state checks to prevent + * Fix `AFURLConnectionOperation -pause` by adding state checks to prevent likely memory issues when resuming (Mattt Thompson) - - * Fix warning caused by miscast of type when + + * Fix warning caused by miscast of type when `CLANG_WARN_IMPLICIT_SIGN_CONVERSION` is set (Steven Fisher) * Fix incomplete implementation warning in example code (Steven Fisher) * Fix warning caused by using `==` comparator on floats (Steven Fisher) - * Fix iOS 4 bug where file URLs return `NSURLResponse` rather than + * Fix iOS 4 bug where file URLs return `NSURLResponse` rather than `NSHTTPURLResponse` objects (Leo Lobato) - * Fix calculation of finished operations in batch operation progress + * Fix calculation of finished operations in batch operation progress callback (Mattt Thompson) - * Fix documentation typos (Steven Fisher, Matthias Wessendorf, + * Fix documentation typos (Steven Fisher, Matthias Wessendorf, jorge@miv.uk.com) - * Fix `hasAcceptableStatusCode` to return true after a network failure (Tony + * Fix `hasAcceptableStatusCode` to return true after a network failure (Tony Million) - * Fix warning about missing prototype for private static method (Stephan + * Fix warning about missing prototype for private static method (Stephan Diederich) - * Fix issue where `nil` content type resulted in unacceptable content type + * Fix issue where `nil` content type resulted in unacceptable content type (Mattt Thompson) * Fix bug related to setup and scheduling of output stream (Stephen Tramer) - * Fix AFContentTypesFromHTTPHeader to correctly handle comma-delimited + * Fix AFContentTypesFromHTTPHeader to correctly handle comma-delimited content types (Peyman, Mattt Thompson, @jsm174) - * Fix crash caused by `_networkReachability` not being set to `NULL` after + * Fix crash caused by `_networkReachability` not being set to `NULL` after releasing (Blake Watters) - * Fix Podspec to correctly import required headers and use ARC (Eloy Durán, + * Fix Podspec to correctly import required headers and use ARC (Eloy Durán, Blake Watters) - * Fix query string parameter escaping to leave square brackets unescaped + * Fix query string parameter escaping to leave square brackets unescaped (Mattt Thompson) * Fix query string parameter encoding of `NSNull` values (Daniel Rinser) - * Fix error caused by referencing `__IPHONE_OS_VERSION_MIN_REQUIRED` without + * Fix error caused by referencing `__IPHONE_OS_VERSION_MIN_REQUIRED` without importing `Availability.h` (Blake Watters) - * Update example to use App.net API, as Twitter shut off its unauthorized + * Update example to use App.net API, as Twitter shut off its unauthorized access to the public timeline (Mattt Thompson) - * Update `AFURLConnectionOperation` to replace `NSAutoReleasePool` with + * Update `AFURLConnectionOperation` to replace `NSAutoReleasePool` with `@autoreleasepool` (Mattt Thompson) - * Update `AFHTTPClient` operation queue to specify -`NSOperationQueueDefaultMaxConcurrentOperationCount` rather than + * Update `AFHTTPClient` operation queue to specify +`NSOperationQueueDefaultMaxConcurrentOperationCount` rather than previously-defined constant (Mattt Thompson) - * Update `AFHTTPClient -initWithBaseURL` to automatically append trailing -slash, so as to fix common issue where default path is not respected without + * Update `AFHTTPClient -initWithBaseURL` to automatically append trailing +slash, so as to fix common issue where default path is not respected without trailing slash (Steven Fisher) - - * Update default `AFHTTPClient` `User-Agent` header strings (Mattt Thompson, + + * Update default `AFHTTPClient` `User-Agent` header strings (Mattt Thompson, Steven Fisher) - + * Update icons for iOS example application (Mattt Thompson) - * Update `numberOfCompletedOperations` variable in progress block to be + * Update `numberOfCompletedOperations` variable in progress block to be renamed to `numberOfFinishedOperations` (Mattt Thompson) From feb55db8599b43a65adffcf8013bd15a7aca7ecd Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 02:22:50 -0400 Subject: [PATCH 0124/1434] Bumping version to 1.2.0 --- AFNetworking.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking.podspec b/AFNetworking.podspec index b7e836b490..c3a8dbbc8d 100644 --- a/AFNetworking.podspec +++ b/AFNetworking.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = 'AFNetworking' - s.version = '1.1.0' + s.version = '1.2.0' s.license = 'MIT' s.summary = 'A delightful iOS and OS X networking framework.' s.homepage = 'https://github.com/AFNetworking/AFNetworking' s.authors = { 'Mattt Thompson' => 'm@mattt.me', 'Scott Raymond' => 'sco@gowalla.com' } - s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => '1.1.0' } + s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => '1.2.0' } s.source_files = 'AFNetworking' s.requires_arc = true From 7e8422f4d24944579377e80cfe79b62efcd26813 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 02:28:55 -0400 Subject: [PATCH 0125/1434] Reformatting CHANGES --- CHANGES | 83 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/CHANGES b/CHANGES index 0e3c9a1062..db12304561 100644 --- a/CHANGES +++ b/CHANGES @@ -1,67 +1,96 @@ = 1.2.0 (2013-03-24) - * Add `SSLPinningMode` property to `AFHTTPClient` (Oliver Letterer, Kevin Harwood, Adam Becevello, Dustin Barker, Mattt Thompson) + * Add `SSLPinningMode` property to `AFHTTPClient` (Oliver Letterer, Kevin +Harwood, Adam Becevello, Dustin Barker, Mattt Thompson) - * Add single quote ("'"), comma (","), and asterix ("*") to escaped URL encoding characters (Eric Florenzano, Marc Nijdam, Garrett Murray) + * Add single quote ("'"), comma (","), and asterix ("*") to escaped URL +encoding characters (Eric Florenzano, Marc Nijdam, Garrett Murray) * Add `credential` property to `AFURLConnectionOperation` (Mattt Thompson) * Add `-setDefaultCredential:` to `AFHTTPClient` - * Fix request stream exhaustion error on authentication challenges (Alex Burgel) + * Add `shouldUseCredentialStorage` property to `AFURLConnectionOperation` +(Mattt Thompson) - * Add `shouldUseCredentialStorage` property to `AFURLConnectionOperation` (Mattt Thompson) + * Add support for repeated key value pairs in `AFHTTPClient` URL query string +(Nick Dawson) - * Add support for repeated key value pairs in `AFHTTPClient` URL query string (Nick Dawson) + * Add `AFMultipartFormData - +appendPartWithFileURL:name:fileName:mimeType:error` (Daniel Rodríguez Troitiño) - * Add `AFMultipartFormData - appendPartWithFileURL:name:fileName:mimeType:error` (Daniel Rodríguez Troitiño) + * Add `AFMultipartFormData - +appendPartWithInputStream:name:fileName:mimeType:` (@joein3d) - * Add `AFMultipartFormData - appendPartWithInputStream:name:fileName:mimeType:` (@joein3d) + * Change SSL pinning to be runtime property on `AFURLConnectionOperation` +rather than defined by macro (Oliver Letterer) - * Change SSL pinning to be runtime property on `AFURLConnectionOperation` rather than defined by macro (Oliver Letterer) + * Change `AFMultipartBodyStream` to `AFMultipartBodyStreamProvider`, vending +one side of a bound CFStream pair rather than subclassing `NSInputStream` (Mike +Ash) - * Change `AFMultipartBodyStream` to `AFMultipartBodyStreamProvider`, vending one side of a bound CFStream pair rather than subclassing `NSInputStream` (Mike Ash) + * Change default `Accept-Language` header in `AFHTTPClient` (@therigu, Mattt +Thompson) - * Change default `Accept-Language` header in `AFHTTPClient` (@therigu, Mattt Thompson) + * Change `AFHTTPClient` operation cancellation to be based on request URL path +rather than absolute URL string (Mattt Thompson) - * Change `AFHTTPClient` operation cancellation to be based on request URL path rather than absolute URL string (Mattt Thompson) + * Change request operation subclass processing queues to use +`DISPATCH_QUEUE_CONCURRENT` (Mattt Thompson) - * Change request operation subclass processing queues to use `DISPATCH_QUEUE_CONCURRENT` (Mattt Thompson) + * Change `UIImageView+AFNetworking` to resolve asymmetry in cached image case +between success block provided and not provided (@Eveets, Mattt Thompson) - * Change `UIImageView+AFNetworking` to resolve asymmetry in cached image case between success block provided and not provided (@Eveets, Mattt Thompson) + * Change `UIImageView+AFNetworking` to compare `NSURLRequest` instead of +`NSURL` to determine if previous request was equivalent (Cédric Luthi) - * Change `UIImageView+AFNetworking` to compare `NSURLRequest` instead of `NSURL` to determine if previous request was equivalent (Cédric Luthi) + * Change `UIImageView+AFNetworking` to only set image if non-`nil` (Sean +Kovacs) - * Change `UIImageView+AFNetworking` to only set image if non-`nil` (Sean Kovacs) + * Change indentation settings to four spaces at the project level (Cédric +Luthi) - * Change indentation settings to four spaces at the project level (Cédric Luthi) + * Change `AFNetworkActivityIndicatorManager` to only update if requests have a +non-`nil` URL (Cédric Luthi) - * Change `AFNetworkActivityIndicatorManager` to only update if requests have a non-`nil` URL (Cédric Luthi) + * Change `UIImageView+AFNetworking` to not do `setHTTPShouldHandleCookies` +(Konstantinos Vaggelakos) - * Change `UIImageView+AFNetworking` to not do `setHTTPShouldHandleCookies` (Konstantinos Vaggelakos) + * Fix request stream exhaustion error on authentication challenges (Alex +Burgel) - * Fix implementation to use `NSURL` methods instead of `CFURL` functions where applicable (Cédric Luthi) + * Fix implementation to use `NSURL` methods instead of `CFURL` functions where +applicable (Cédric Luthi) * Fix race condition in `UIImageView+AFNetworking` (Peyman) - * Fix `responseJSON`, `responseString`, and `responseStringEncoding` to be threadsafe (Jon Parise, Mattt Thompson) + * Fix `responseJSON`, `responseString`, and `responseStringEncoding` to be +threadsafe (Jon Parise, Mattt Thompson) - * Fix `AFContentTypeForPathExtension` to ensure non-`NULL` content return value (Zach Waugh) + * Fix `AFContentTypeForPathExtension` to ensure non-`NULL` content return +value (Zach Waugh) * Fix documentation for `appendPartWithFileURL:name:error:` (Daniel Rodríguez Troitiño) - * Fix request operation subclass processing queues to initialize with `dispatch_once` (Sasmito Adibowo) + * Fix request operation subclass processing queues to initialize with +`dispatch_once` (Sasmito Adibowo) - * Fix posting of `AFNetworkingOperationDidStartNotification` and `AFNetworkingOperationDidFinishNotification` to avoid crashes when logging in response to notifications (Blake Watters) + * Fix posting of `AFNetworkingOperationDidStartNotification` and +`AFNetworkingOperationDidFinishNotification` to avoid crashes when logging in +response to notifications (Blake Watters) - * Fix ordering of registered operation consultation in `AFHTTPClient` (Joel Parsons) + * Fix ordering of registered operation consultation in `AFHTTPClient` (Joel +Parsons) - * Fix warning: multiple methods named 'postNotificationName:object:' found [-Wstrict-selector-match] (Oliver Jones) + * Fix warning: multiple methods named 'postNotificationName:object:' found +[-Wstrict-selector-match] (Oliver Jones) - * Fix warning: multiple methods named 'objectForKey:' found [-Wstrict-selector-match] (Oliver Jones) + * Fix warning: multiple methods named 'objectForKey:' found +[-Wstrict-selector-match] (Oliver Jones) - * Fix warning: weak receiver may be unpredictably set to nil [-Wreceiver-is-weak] (Oliver Jones) + * Fix warning: weak receiver may be unpredictably set to nil +[-Wreceiver-is-weak] (Oliver Jones) * Fix missing #pragma clang diagnostic pop (Steven Fisher) From 566a40f469a07f88be5b4669fd750f98973fe852 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 24 Mar 2013 02:29:59 -0400 Subject: [PATCH 0126/1434] Reformatting CHANGES --- CHANGES | 82 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 25 deletions(-) diff --git a/CHANGES b/CHANGES index db12304561..0767b58e2a 100644 --- a/CHANGES +++ b/CHANGES @@ -96,68 +96,100 @@ Parsons) = 1.1.0 (2012-12-27) - * Add optional SSL certificate pinning with `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` (Dustin Barker) + * Add optional SSL certificate pinning with `#define +_AFNETWORKING_PIN_SSL_CERTIFICATES_` (Dustin Barker) - * Add `responseStringEncoding` property to `AFURLConnectionOperation` (Mattt Thompson) + * Add `responseStringEncoding` property to `AFURLConnectionOperation` (Mattt +Thompson) - * Add `userInfo` property to `AFURLConnectionOperation` (Mattt Thompson, Steven Fisher) + * Add `userInfo` property to `AFURLConnectionOperation` (Mattt Thompson, +Steven Fisher) - * Change behavior to cause a failure when an operation is cancelled (Daniel Tull) + * Change behavior to cause a failure when an operation is cancelled (Daniel +Tull) * Change return type of class constructors to `instancetype` (@guykogus) - * Change notifications to always being posted on an asynchronously-dispatched block run on the main queue (Evadne Wu, Mattt Thompson) + * Change notifications to always being posted on an asynchronously-dispatched +block run on the main queue (Evadne Wu, Mattt Thompson) - * Change from NSLocalizedString to NSLocalizedStringFromTable with AFNetworking.strings table for localized strings (Cédric Luthi) + * Change from NSLocalizedString to NSLocalizedStringFromTable with +AFNetworking.strings table for localized strings (Cédric Luthi) - * Change `-appendPartWithHeaders:body:` to add assertion handler for existence of body data parameter (Jonathan Beilin) + * Change `-appendPartWithHeaders:body:` to add assertion handler for existence +of body data parameter (Jonathan Beilin) - * Change `AFHTTPRequestOperation -responseString` to follow guidelines from RFC 2616 regarding the use of string encoding when none is specified in the response (Jorge Bernal) + * Change `AFHTTPRequestOperation -responseString` to follow guidelines from +RFC 2616 regarding the use of string encoding when none is specified in the +response (Jorge Bernal) - * Change AFHTTPClient parameter serialization dictionary keys with `caseInsensitiveCompare:` to ensure + * Change AFHTTPClient parameter serialization dictionary keys with +`caseInsensitiveCompare:` to ensure deterministic ordering of query string parameters, which may otherwise cause ambiguous representations of nested parameters (James Coleman, Mattt Thompson) - * Fix -Wstrict-selector-match warnings raised by Xcode 4.6DP3 (Jesse Collis, Cédric Luthi) + * Fix -Wstrict-selector-match warnings raised by Xcode 4.6DP3 (Jesse Collis, +Cédric Luthi) - * Fix NSJSONSerialization crash with Unicode character escapes in JSON response (Mathijs Kadijk) + * Fix NSJSONSerialization crash with Unicode character escapes in JSON +response (Mathijs Kadijk) - * Fix issue with early return in -startMonitoringNetworkReachability if network reachability object could not be created (i.e. invalid hostnames) (Basil Shkara) + * Fix issue with early return in -startMonitoringNetworkReachability if +network reachability object could not be created (i.e. invalid hostnames) +(Basil Shkara) - * Fix retain cycles in AFImageRequestOperation.m and AFHTTPClient.m caused by strong references within blocks (Nick Forge) + * Fix retain cycles in AFImageRequestOperation.m and AFHTTPClient.m caused by +strong references within blocks (Nick Forge) - * Fix issue caused by Rails behavior of returning a single space in head :ok responses, which is interpreted as invalid (Sebastian Ludwig) + * Fix issue caused by Rails behavior of returning a single space in head :ok +responses, which is interpreted as invalid (Sebastian Ludwig) - * Fix issue in streaming multipart upload, where final encapsulation boundary would not be appended if it was larger than the available buffer, causing a potential timeout (Tomohisa Takaoka, David Kasper) + * Fix issue in streaming multipart upload, where final encapsulation boundary +would not be appended if it was larger than the available buffer, causing a +potential timeout (Tomohisa Takaoka, David Kasper) * Fix memory leak of network reachability callback block (Mattt Thompson) - * Fix `-initWithCoder:` for `AFURLConnectionOperation` and `AFHTTPClient` to cast scalar types (Mattt Thompson) + * Fix `-initWithCoder:` for `AFURLConnectionOperation` and `AFHTTPClient` to +cast scalar types (Mattt Thompson) - * Fix bug in `-enqueueBatchOfHTTPRequestOperations:...` to by using `addOperations:waitUntilFinished:` instead of adding each operation individually. (Mattt Thompson) + * Fix bug in `-enqueueBatchOfHTTPRequestOperations:...` to by using +`addOperations:waitUntilFinished:` instead of adding each operation +individually. (Mattt Thompson) - * Change `#warning` messages of checks for `CoreServices` and `MobileCoreServices` to message according to the build target platform (Mattt Thompson) + * Change `#warning` messages of checks for `CoreServices` and +`MobileCoreServices` to message according to the build target platform (Mattt +Thompson) - * Change `AFQueryStringFromParametersWithEncoding` to create keys string representations using the description method as specified in documentation (Cédric Luthi) + * Change `AFQueryStringFromParametersWithEncoding` to create keys string +representations using the description method as specified in documentation +(Cédric Luthi) * Fix __unused keywords for better Xcode indexing (Christian Rasmussen) * Fix warning: unused parameter 'x' [-Werror,-Wunused-parameter] (Oliver Jones) - * Fix warning: property is assumed atomic by default [-Werror,-Wimplicit-atomic-properties] (Oliver Jones) + * Fix warning: property is assumed atomic by default +[-Werror,-Wimplicit-atomic-properties] (Oliver Jones) - * Fix warning: weak receiver may be unpredictably null in ARC mode [-Werror,-Wreceiver-is-weak] (Oliver Jones) + * Fix warning: weak receiver may be unpredictably null in ARC mode +[-Werror,-Wreceiver-is-weak] (Oliver Jones) - * Fix warning: multiple methods named 'selector' found [-Werror,-Wstrict-selector-match] (Oliver Jones) + * Fix warning: multiple methods named 'selector' found +[-Werror,-Wstrict-selector-match] (Oliver Jones) * Fix warning: 'macro' is not defined, evaluates to 0 (Oliver Jones) - * Fix warning: atomic by default property 'X' has a user (Oliver Jones)defined getter (property should be marked 'atomic' if this is intended) [-Werror, -Wcustom-atomic-properties] (Oliver Jones) + * Fix warning: atomic by default property 'X' has a user (Oliver Jones)defined +getter (property should be marked 'atomic' if this is intended) [-Werror, +-Wcustom-atomic-properties] (Oliver Jones) - * Fix warning: 'response' was marked unused but was used [-Werror,-Wused-but-marked-unused] (Oliver Jones) + * Fix warning: 'response' was marked unused but was used +[-Werror,-Wused-but-marked-unused] (Oliver Jones) - * Fix warning: enumeration value 'AFFinalBoundaryPhase' not explicitly handled in switch [-Werror,-Wswitch-enum] (Oliver Jones) + * Fix warning: enumeration value 'AFFinalBoundaryPhase' not explicitly handled +in switch [-Werror,-Wswitch-enum] (Oliver Jones) = 1.0.1 / 2012-11-01 From 71157c90a0a9dc1a66b0d6bde7da23467134fa5c Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Sun, 24 Mar 2013 08:45:36 -0500 Subject: [PATCH 0127/1434] Small correction to SSL Pinning documentation --- AFNetworking/AFURLConnectionOperation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index b3a94db106..c50ce24858 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -315,7 +315,7 @@ NSCoding, NSCopying> ///---------------- /** - ## Network Reachability + ## SSL Pinning Options The following constants are provided by `AFURLConnectionOperation` as possible SSL Pinning options. From 48558d7b48ae3a2412014200e4f3bcee96fddec9 Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Mon, 25 Mar 2013 17:15:43 -0500 Subject: [PATCH 0128/1434] Removed invalid SSL macro from new 1.2.0 code --- AFNetworking/AFURLConnectionOperation.m | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index ca9780c885..9b593810e7 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -581,21 +581,22 @@ - (void)connection:(NSURLConnection *)connection break; } case AFSSLPinningModeNone: { -#ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ - NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; -#else - SecTrustResultType result = 0; - OSStatus status = SecTrustEvaluate(serverTrust, &result); - NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); - - if (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed) { + if(self.allowInvalidSSLCertificate == YES){ NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] cancelAuthenticationChallenge:challenge]; } -#endif + else { + SecTrustResultType result = 0; + OSStatus status = SecTrustEvaluate(serverTrust, &result); + NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); + + if (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; + } + } break; } } From a150b95f095db21376f4e2e4c166f4495c5d6ffc Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Mon, 25 Mar 2013 17:18:12 -0500 Subject: [PATCH 0129/1434] Updated documentation --- AFNetworking/AFURLConnectionOperation.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 42c74d48d9..eb219b5936 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -128,7 +128,7 @@ NSCoding, NSCopying> @property (readonly, nonatomic, strong) NSError *error; /** - The flag to determine if the connection should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to YES. Otherwise, this property defaults to NO. + The flag to determine if the connection should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to YES for backwards compatibility support. Otherwise, this property defaults to NO. */ @property (nonatomic,assign) BOOL allowInvalidSSLCertificate; @@ -285,7 +285,7 @@ NSCoding, NSCopying> @param block A block object to be executed to determine whether the connection should be able to respond to a protection space's form of authentication. The block has a `BOOL` return type and takes two arguments: the URL connection object, and the protection space to authenticate against. - @discussion If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. + @discussion If `allowInvalidSSLCertificate` is set to YES, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. */ - (void)setAuthenticationAgainstProtectionSpaceBlock:(BOOL (^)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace))block; @@ -294,7 +294,7 @@ NSCoding, NSCopying> @param block A block object to be executed when the connection must authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. - @discussion If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. + @discussion If `allowInvalidSSLCertificate` is set to YES, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. */ - (void)setAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; From f64ce9143de762a09a5c2e03f232b4975a38d16d Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Mon, 25 Mar 2013 17:21:56 -0500 Subject: [PATCH 0130/1434] Added invalidSSL flag to AFHTTPClient --- AFNetworking/AFHTTPClient.h | 5 +++++ AFNetworking/AFHTTPClient.m | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 5551f5d771..90694f568c 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -145,6 +145,11 @@ typedef enum { @property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode defaultSSLPinningMode; #endif +/** + The flag to determine if each `AFHTTPRequestOperation` that will be enqueued with `enqueueHTTPRequestOperation:` should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to YES for backwards compatibility support. Otherwise, this property defaults to NO. + */ +@property (nonatomic,assign) BOOL allowInvalidSSLCertificate; + ///--------------------------------------------- /// @name Creating and Initializing HTTP Clients ///--------------------------------------------- diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index bd0cab2de8..9c3cd3c9ff 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -263,6 +263,11 @@ - (id)initWithBaseURL:(NSURL *)url { self.operationQueue = [[NSOperationQueue alloc] init]; [self.operationQueue setMaxConcurrentOperationCount:NSOperationQueueDefaultMaxConcurrentOperationCount]; + //This ifdef has been added for backwards compatibility purposes +#ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ + self.allowInvalidSSLCertificate = YES; +#endif + return self; } From 22f5153bb8a8fdd9cc0254150c3d60a1d136da27 Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Mon, 25 Mar 2013 17:26:28 -0500 Subject: [PATCH 0131/1434] Set the operation flag in HTTPRequestOperationWithRequest --- AFNetworking/AFHTTPClient.h | 2 +- AFNetworking/AFHTTPClient.m | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 90694f568c..8e1a67b505 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -146,7 +146,7 @@ typedef enum { #endif /** - The flag to determine if each `AFHTTPRequestOperation` that will be enqueued with `enqueueHTTPRequestOperation:` should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to YES for backwards compatibility support. Otherwise, this property defaults to NO. + The flag to determine if each `AFHTTPRequestOperation` is created in `HTTPRequestOperationWithRequest` should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to YES for backwards compatibility support. Otherwise, this property defaults to NO. */ @property (nonatomic,assign) BOOL allowInvalidSSLCertificate; diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 9c3cd3c9ff..8ecf6439a7 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -541,6 +541,7 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ operation.SSLPinningMode = self.defaultSSLPinningMode; #endif + operation.allowInvalidSSLCertificate = self.allowInvalidSSLCertificate; return operation; } From 8e5dac8d42638e8930054cbfd97f5d6f7a14f01b Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Mon, 25 Mar 2013 17:28:28 -0500 Subject: [PATCH 0132/1434] Documentation update --- AFNetworking/AFHTTPClient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 8e1a67b505..17b3004f81 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -146,7 +146,7 @@ typedef enum { #endif /** - The flag to determine if each `AFHTTPRequestOperation` is created in `HTTPRequestOperationWithRequest` should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to YES for backwards compatibility support. Otherwise, this property defaults to NO. + The flag to determine if each `AFHTTPRequestOperation` that is created in `HTTPRequestOperationWithRequest` should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to YES for backwards compatibility support. Otherwise, this property defaults to NO. */ @property (nonatomic,assign) BOOL allowInvalidSSLCertificate; From 7745e8f444ae3009598812f797355fe0a3acc0d2 Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Wed, 27 Mar 2013 15:06:47 +0100 Subject: [PATCH 0133/1434] Refactoring some loops to fast enumeration. --- AFNetworking/AFHTTPClient.m | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index bd0cab2de8..f349796c43 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -149,22 +149,22 @@ - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding NSDictionary *dictionary = value; // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(caseInsensitiveCompare:)]; - [[[dictionary allKeys] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]] enumerateObjectsUsingBlock:^(id nestedKey, __unused NSUInteger idx, __unused BOOL *stop) { - id nestedValue = [dictionary objectForKey:nestedKey]; + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + id nestedValue = dictionary[nestedKey]; if (nestedValue) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; } - }]; + } } else if ([value isKindOfClass:[NSArray class]]) { NSArray *array = value; - [array enumerateObjectsUsingBlock:^(id nestedValue, __unused NSUInteger idx, __unused BOOL *stop) { + for (id nestedValue in array) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; - }]; + } } else if ([value isKindOfClass:[NSSet class]]) { NSSet *set = value; - [set enumerateObjectsUsingBlock:^(id obj, BOOL *stop) { + for (id obj in set) { [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)]; - }]; + } } else { [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; } @@ -605,12 +605,12 @@ - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations originalCompletionBlock(); } - __block NSUInteger numberOfFinishedOperations = 0; - [operations enumerateObjectsUsingBlock:^(id obj, __unused NSUInteger idx, __unused BOOL *stop) { - if ([(NSOperation *)obj isFinished]) { + NSUInteger numberOfFinishedOperations = 0; + for (NSOperation *operation in operations) { + if (operation.isFinished) { numberOfFinishedOperations++; } - }]; + } if (progressBlock) { progressBlock(numberOfFinishedOperations, [operations count]); From a0f1f83a2b2cfb29129cbf3680203c5141bb4dc1 Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Wed, 27 Mar 2013 11:19:51 +0100 Subject: [PATCH 0134/1434] Pinning certificates will now trust all derived certificates. --- AFNetworking/AFURLConnectionOperation.m | 90 ++++++++++++++----------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 51cfd6b5ea..ae1bea93f2 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -542,57 +542,71 @@ - (void)connection:(NSURLConnection *)connection { if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, 0); - NSData *certificateData = (__bridge_transfer NSData *)SecCertificateCopyData(certificate); - - if ([[[self class] pinnedCertificates] containsObject:certificateData]) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - switch (self.SSLPinningMode) { - case AFSSLPinningModePublicKey: { - id publicKey = (__bridge_transfer id)SecTrustCopyPublicKey(serverTrust); - + + SecPolicyRef policy = SecPolicyCreateBasicX509(); + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:certificateCount]; + + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + + if (self.SSLPinningMode == AFSSLPinningModeCertificate) { + [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; + } else if (self.SSLPinningMode == AFSSLPinningModePublicKey) { + SecTrustRef trust = NULL; + OSStatus status = SecTrustCreateWithCertificates(certificate, policy, &trust); + NSAssert(status == noErr, @"SecTrustCreateWithCertificates error: %ld", (long int)status); + + [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; + + CFRelease(trust); + } + } + + CFRelease(policy); + + switch (self.SSLPinningMode) { + case AFSSLPinningModePublicKey: { + for (id publicKey in trustChain) { if ([[self.class pinnedPublicKeys] containsObject:publicKey]) { NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] cancelAuthenticationChallenge:challenge]; + return; } - - break; } - case AFSSLPinningModeCertificate: { - SecCertificateRef serverCertificate = SecTrustGetCertificateAtIndex(serverTrust, 0); - NSData *serverCertificateData = (__bridge_transfer NSData *)SecCertificateCopyData(serverCertificate); - - if ([[[self class] pinnedCertificates] containsObject:serverCertificateData]) { + + [[challenge sender] cancelAuthenticationChallenge:challenge]; + break; + } + case AFSSLPinningModeCertificate: { + for (id serverCertificateData in trustChain) { + if ([[self.class pinnedCertificates] containsObject:serverCertificateData]) { NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] cancelAuthenticationChallenge:challenge]; + return; } - - break; } - case AFSSLPinningModeNone: { + + [[challenge sender] cancelAuthenticationChallenge:challenge]; + break; + } + case AFSSLPinningModeNone: { #ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; +#else + SecTrustResultType result = 0; + OSStatus status = SecTrustEvaluate(serverTrust, &result); + NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); + + if (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed) { NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; -#else - SecTrustResultType result = 0; - OSStatus status = SecTrustEvaluate(serverTrust, &result); - NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); - - if (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] cancelAuthenticationChallenge:challenge]; - } -#endif - break; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; } +#endif + break; } } } From c80bfef9e3134df3d5480c14531e38ce35fa2b2b Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 2 Apr 2013 11:24:38 -0700 Subject: [PATCH 0135/1434] Fix macro to work correctly under 10.7 SDK / iOS 4 SDK --- AFNetworking/AFURLConnectionOperation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index c50ce24858..d240a7ca63 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -93,8 +93,8 @@ typedef enum { #endif @interface AFURLConnectionOperation : NSOperation = __IPHONE_5_0) || \ - (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8) +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__IPHONE_5_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && defined(__MAC_10_8) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8) NSURLConnectionDataDelegate, #endif NSCoding, NSCopying> From bc7544bb8aa77bed28623ffbdcf01a2e41724a13 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 2 Apr 2013 12:22:53 -0700 Subject: [PATCH 0136/1434] Use Apple's recommended style, and fix so it works under 10.7 or pre-5.0 --- AFNetworking/AFURLConnectionOperation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index d240a7ca63..8f8cd4ec48 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -93,8 +93,8 @@ typedef enum { #endif @interface AFURLConnectionOperation : NSOperation = __IPHONE_5_0) || \ - (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && defined(__MAC_10_8) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8) +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080) NSURLConnectionDataDelegate, #endif NSCoding, NSCopying> From bc149aa3c2f1b5b143b80012f7d0046eb42dafb8 Mon Sep 17 00:00:00 2001 From: Michele Date: Tue, 2 Apr 2013 17:13:30 -0700 Subject: [PATCH 0137/1434] Removed all @discussion tags, since they are not supported. --- AFNetworking/AFHTTPClient.h | 36 +++++++++---------- AFNetworking/AFHTTPRequestOperation.h | 4 +-- .../AFNetworkActivityIndicatorManager.h | 2 +- AFNetworking/AFURLConnectionOperation.h | 26 +++++++------- AFNetworking/UIImageView+AFNetworking.h | 10 +++--- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 5551f5d771..ed7b208b62 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -160,11 +160,11 @@ typedef enum { /** Initializes an `AFHTTPClient` object with the specified base URL. + + This is the designated initializer. @param url The base URL for the HTTP client. This argument must not be `nil`. - @discussion This is the designated initializer. - @return The newly-initialized HTTP client */ - (id)initWithBaseURL:(NSURL *)url; @@ -191,11 +191,11 @@ typedef enum { /** Attempts to register a subclass of `AFHTTPRequestOperation`, adding it to a chain to automatically generate request operations from a URL request. + When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list. + @param operationClass The subclass of `AFHTTPRequestOperation` to register @return `YES` if the registration is successful, `NO` otherwise. The only failure condition is if `operationClass` is not a subclass of `AFHTTPRequestOperation`. - - @discussion When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list. */ - (BOOL)registerHTTPOperationClass:(Class)operationClass; @@ -283,13 +283,13 @@ typedef enum { /** Creates an `NSMutableURLRequest` object with the specified HTTP method and path, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2 + Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. + @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`. @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and set in the request HTTP body. @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. This can be used to upload files, encode HTTP body as JSON or XML, or specify multiple values for the same parameter, as one might for array values. - @discussion Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. - @return An `NSMutableURLRequest` object */ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method @@ -327,11 +327,11 @@ typedef enum { /** Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path. + + This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property. @param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled. @param path The path appended to the HTTP client base URL to match against the cancelled requests. If `nil`, no path will be appended to the base URL. - - @discussion This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property. */ - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path; @@ -342,11 +342,11 @@ typedef enum { /** Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue for each specified request object into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes. + Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters. + @param urlRequests The `NSURLRequest` objects used to create and enqueue operations. @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations. @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations. - - @discussion Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters. */ - (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock @@ -506,13 +506,13 @@ typedef enum { /** Returns a query string constructed by a set of parameters, using the specified encoding. + Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&". + + If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component. + @param parameters The parameters used to construct the query string @param encoding The encoding to use in constructing the query string. If you are uncertain of the correct encoding, you should use UTF-8 (`NSUTF8StringEncoding`), which is the encoding designated by RFC 3986 as the correct encoding for use in URLs. - @discussion Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&". - - If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component. - @return A percent-escaped query string */ extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding); @@ -545,13 +545,13 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; /** Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary. + The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. @param name The name to be associated with the specified data. This parameter must not be `nil`. @param error If an error occurs, upon return contains an `NSError` object that describes the problem. @return `YES` if the file data was successfully appended, otherwise `NO`. - - @discussion The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. */ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL name:(NSString *)name @@ -625,10 +625,10 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; /** Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. + When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. + @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 32kb. @param delay Duration of delay each time a packet is read. By default, no delay is set. - - @discussion When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. */ - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes delay:(NSTimeInterval)delay; diff --git a/AFNetworking/AFHTTPRequestOperation.h b/AFNetworking/AFHTTPRequestOperation.h index 2ec99ac6bd..b40e3d5067 100644 --- a/AFNetworking/AFHTTPRequestOperation.h +++ b/AFNetworking/AFHTTPRequestOperation.h @@ -112,10 +112,10 @@ /** Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed. + This method should be overridden in subclasses in order to specify the response object passed into the success block. + @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request. @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request. - - @discussion This method should be overridden in subclasses in order to specify the response object passed into the success block. */ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.h b/AFNetworking/AFNetworkActivityIndicatorManager.h index bac7b5a27c..714193baf3 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.h +++ b/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -44,7 +44,7 @@ /** A Boolean value indicating whether the manager is enabled. - @discussion If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. + If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. */ @property (nonatomic, assign, getter = isEnabled) BOOL enabled; diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index c50ce24858..50913ce770 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -144,7 +144,7 @@ NSCoding, NSCopying> /** The string encoding of the response. - @discussion If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. + If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. */ @property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; @@ -155,21 +155,21 @@ NSCoding, NSCopying> /** Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. - @discussion This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. + This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. */ @property (nonatomic, assign) BOOL shouldUseCredentialStorage; /** The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. - @discussion This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. + This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. */ @property (nonatomic, strong) NSURLCredential *credential; /** The pinning mode which will be used for SSL connections. `AFSSLPinningModePublicKey` by default. - @discussion To enable SSL Pinning, `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` in `Prefix.pch`. Also, make sure that the Security framework is linked with the binary. See the "SSL Pinning" section in the `AFURLConnectionOperation`" header for more information. + To enable SSL Pinning, `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` in `Prefix.pch`. Also, make sure that the Security framework is linked with the binary. See the "SSL Pinning" section in the `AFURLConnectionOperation`" header for more information. */ #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ @property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode SSLPinningMode; @@ -182,14 +182,14 @@ NSCoding, NSCopying> /** The input stream used to read data to be sent during the request. - @discussion This property acts as a proxy to the `HTTPBodyStream` property of `request`. + This property acts as a proxy to the `HTTPBodyStream` property of `request`. */ @property (nonatomic, strong) NSInputStream *inputStream; /** The output stream that is used to write data received until the request is finished. - @discussion By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set. + By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set. */ @property (nonatomic, strong) NSOutputStream *outputStream; @@ -208,10 +208,10 @@ NSCoding, NSCopying> /** Initializes and returns a newly allocated operation object with a url connection configured with the specified url request. - + + This is the designated initializer. + @param urlRequest The request object to be used by the operation connection. - - @discussion This is the designated initializer. */ - (id)initWithRequest:(NSURLRequest *)urlRequest; @@ -222,7 +222,7 @@ NSCoding, NSCopying> /** Pauses the execution of the request operation. - @discussion A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect. + A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect. */ - (void)pause; @@ -236,7 +236,7 @@ NSCoding, NSCopying> /** Resumes the execution of the paused request operation. - @discussion Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request. + Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request. */ - (void)resume; @@ -280,7 +280,7 @@ NSCoding, NSCopying> @param block A block object to be executed to determine whether the connection should be able to respond to a protection space's form of authentication. The block has a `BOOL` return type and takes two arguments: the URL connection object, and the protection space to authenticate against. - @discussion If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. + If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. */ - (void)setAuthenticationAgainstProtectionSpaceBlock:(BOOL (^)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace))block; @@ -289,7 +289,7 @@ NSCoding, NSCopying> @param block A block object to be executed when the connection must authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. - @discussion If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. + If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. */ - (void)setAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; diff --git a/AFNetworking/UIImageView+AFNetworking.h b/AFNetworking/UIImageView+AFNetworking.h index f9a389f614..bafb7901ea 100644 --- a/AFNetworking/UIImageView+AFNetworking.h +++ b/AFNetworking/UIImageView+AFNetworking.h @@ -36,7 +36,7 @@ /** Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL, and sets it the request is finished. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - @discussion By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` @param url The URL used for the image request. */ @@ -45,23 +45,23 @@ /** Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + @param url The URL used for the image request. @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. - - @discussion By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` */ - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholderImage; /** Creates and enqueues an image request operation, which asynchronously downloads the image with the specified URL request object. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is executed. @param urlRequest The URL request used for the image request. @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. @param success A block to be executed when the image request operation finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the request and response parameters will be `nil`. @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. - - @discussion If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is executed. */ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest placeholderImage:(UIImage *)placeholderImage From ab00b9559caabecb4c0b855dfe45fc4b727299e9 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Sat, 6 Apr 2013 12:11:29 +0200 Subject: [PATCH 0138/1434] Fixing AFImageRequestOperation to use [self alloc] instead of explicit class in class method in order to preserve behavior in subclasses Signed-off-by: Mattt Thompson --- AFNetworking/AFImageRequestOperation.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index 0a0390f818..cfac8d9250 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -75,7 +75,7 @@ + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure { - AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest]; + AFImageRequestOperation *requestOperation = [(AFImageRequestOperation *)[self alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { if (success) { UIImage *image = responseObject; @@ -106,7 +106,7 @@ + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure { - AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest]; + AFImageRequestOperation *requestOperation = [(AFImageRequestOperation *)[self alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { if (success) { NSImage *image = responseObject; From bab6a8b28f947731f95280e4f5a0101cf0b7a95b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 6 Apr 2013 12:42:01 +0200 Subject: [PATCH 0139/1434] Set AFNetworking thread name Signed-off-by: Mattt Thompson --- AFNetworking/AFURLConnectionOperation.m | 1 + 1 file changed, 1 insertion(+) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 51cfd6b5ea..0d9bac7ca3 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -162,6 +162,7 @@ @implementation AFURLConnectionOperation + (void) __attribute__((noreturn)) networkRequestThreadEntryPoint:(id)__unused object { do { @autoreleasepool { + [[NSThread currentThread] setName:@"AFNetworking"]; [[NSRunLoop currentRunLoop] run]; } } while (YES); From 205a8aa7e3da2cece0491f41dfb89b3cb267ee11 Mon Sep 17 00:00:00 2001 From: Sebastian Utz Date: Sat, 6 Apr 2013 15:42:10 +0200 Subject: [PATCH 0140/1434] Only encode JSON with UTF8, following recommendation of NSJSONSerialization documentation Signed-off-by: Mattt Thompson --- AFNetworking/AFJSONRequestOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 008aaccbbb..ac7423a1a0 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -75,7 +75,7 @@ - (id)responseJSON { } else { // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character // See http://stackoverflow.com/a/12843465/157142 - NSData *JSONData = [self.responseString dataUsingEncoding:self.responseStringEncoding]; + NSData *JSONData = [self.responseString dataUsingEncoding:NSUTF8StringEncoding]; self.responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:self.JSONReadingOptions error:&error]; } From 06a9c63eade3ee48f1b6d696d0d4cad13c152da5 Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Sat, 6 Apr 2013 11:04:02 -0500 Subject: [PATCH 0141/1434] Attempting to add the pinning mode as an example. --- .../project.pbxproj | 4 ++++ Example/Classes/AFAppDotNetAPIClient.m | 2 ++ Example/adn.cer | Bin 0 -> 1707 bytes 3 files changed, 6 insertions(+) create mode 100644 Example/adn.cer diff --git a/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj b/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj index d89b181a36..f3e7dd8740 100644 --- a/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj +++ b/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 2982AD3217107C0000FFF048 /* adn.cer in Resources */ = {isa = PBXBuildFile; fileRef = 2982AD3117107C0000FFF048 /* adn.cer */; }; F8129C7415910C37009BFE23 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C7215910C37009BFE23 /* AppDelegate.m */; }; F818101615E6A0C600EF93C2 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */; }; F88812F016C533D6003C8B8C /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469E013957DF100DB05C8 /* Security.framework */; }; @@ -40,6 +41,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 2982AD3117107C0000FFF048 /* adn.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = adn.cer; sourceTree = SOURCE_ROOT; }; 50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; F8129C3815910830009BFE23 /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = SOURCE_ROOT; }; F8129C7215910C37009BFE23 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; }; @@ -198,6 +200,7 @@ F8E4696B1395739D00DB05C8 /* Supporting Files */ = { isa = PBXGroup; children = ( + 2982AD3117107C0000FFF048 /* adn.cer */, F8DA09E31396AC040057D0CC /* main.m */, F8129C3815910830009BFE23 /* Prefix.pch */, F8E4696C1395739D00DB05C8 /* iOS-Info.plist */, @@ -319,6 +322,7 @@ F8A847C1161F51A300940F39 /* Default-568h@2x.png in Resources */, F8A847C3161F523E00940F39 /* Default.png in Resources */, F8A847C5161F524200940F39 /* Default@2x.png in Resources */, + 2982AD3217107C0000FFF048 /* adn.cer in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Example/Classes/AFAppDotNetAPIClient.m b/Example/Classes/AFAppDotNetAPIClient.m index f0bc2f1e7f..7859d9094f 100644 --- a/Example/Classes/AFAppDotNetAPIClient.m +++ b/Example/Classes/AFAppDotNetAPIClient.m @@ -49,6 +49,8 @@ - (id)initWithBaseURL:(NSURL *)url { // Accept HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1 [self setDefaultHeader:@"Accept" value:@"application/json"]; + [self setDefaultSSLPinningMode:AFSSLPinningModePublicKey]; + return self; } diff --git a/Example/adn.cer b/Example/adn.cer new file mode 100644 index 0000000000000000000000000000000000000000..614e784664114ecc09182da430cae9d8aa05863c GIT binary patch literal 1707 zcmZ`(4Nz276ux(VVPzHF6;J}60*WBZT~R1>9M*MpNpO%K|4SdcZFE8J0sR76W8bPeJ|?VXjD` z5aed7XCehLWQu^5teMp^oQq1c8Pu~-FoCBi0*i`@R7UJFV3*2Zx2mI2BykB9FHA(} zS#v(6aXJe*+Gb!VttLJZg$K*ki_l_qG8+4B#%3Z)LWvl}zs<-#S%(5mCt3XzGA(Uk zO?J-4(&`|jB%o9w&!%nEDw3Ub8tm!_6h?5FA}E91$rz~&#>moCI-TcSNYty;Gf?1| z#sL3V742}SY>W%>aPITp0*ZlWjRCMlpy)2|-V{>5V z!nO*gf5o!QPNp*Rex2)_El{rY8rAGmX*=w{B=~*5C;V96erHR~wvq7XDgUo^$f6 zq13^ofryaLZ@$uZ@Y5e(Uh~ELweubi_KD+;J??I5T32NpIIG>$Elc53YrD9+KYK&> z%Z|Ucw{cam95p8mk9s0LYcDH)yZ5m4RL@)y4Fy67UQIJUaU}$f3T*iyxE!O6H>mJ=|nEz%BKkl9` z!Z*nOa|gWCcNtSj`e_i3ibO(z*gH;-CUl8koCG(jR0t<_0m35z$=C0SnMGh$M-bI!xllugTh%zbz+;I z;p1mjpaXEhk!P_*+vVuOM#U`J~hC9StSFsnXP9SN6Q%fm*>Lg6dDTy&gLRlTlNajeP#obR&`C7{_%z6GDg4WPv~B^ bvS3-y)jPAVR@|7mX=}|R?&vB0ufo3p3#}Ki literal 0 HcmV?d00001 From ebccca44da3591a2611dce46d2a0b32097e224da Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Sat, 6 Apr 2013 11:30:47 -0500 Subject: [PATCH 0142/1434] Fixed SSL Pinning - SSL Pinning switch case was not being applied if a .cer file was found in the bundle. - SSL Public Key pinning was broken because we didn't make a call to SecTrustEvaluate before SecTrustCopyPublicKey --- AFNetworking/AFURLConnectionOperation.m | 89 ++++++++++++------------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 0d9bac7ca3..0ecbdb8cc0 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -218,7 +218,13 @@ + (NSArray *)pinnedPublicKeys { OSStatus status = SecTrustCreateWithCertificates(certificates, policy, &allowedTrust); NSAssert(status == noErr, @"SecTrustCreateWithCertificates error: %ld", (long int)status); + SecTrustResultType result = 0; + status = SecTrustEvaluate(allowedTrust, &result); + NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); + SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust); + + NSCParameterAssert(allowedPublicKey); [publicKeys addObject:(__bridge_transfer id)allowedPublicKey]; CFRelease(allowedTrust); @@ -543,59 +549,52 @@ - (void)connection:(NSURLConnection *)connection { if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, 0); - NSData *certificateData = (__bridge_transfer NSData *)SecCertificateCopyData(certificate); - - if ([[[self class] pinnedCertificates] containsObject:certificateData]) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - switch (self.SSLPinningMode) { - case AFSSLPinningModePublicKey: { - id publicKey = (__bridge_transfer id)SecTrustCopyPublicKey(serverTrust); - - if ([[self.class pinnedPublicKeys] containsObject:publicKey]) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] cancelAuthenticationChallenge:challenge]; - } - - break; + switch (self.SSLPinningMode) { + case AFSSLPinningModePublicKey: { + id publicKey = (__bridge_transfer id)SecTrustCopyPublicKey(serverTrust); + + if ([[self.class pinnedPublicKeys] containsObject:publicKey]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; } - case AFSSLPinningModeCertificate: { - SecCertificateRef serverCertificate = SecTrustGetCertificateAtIndex(serverTrust, 0); - NSData *serverCertificateData = (__bridge_transfer NSData *)SecCertificateCopyData(serverCertificate); - - if ([[[self class] pinnedCertificates] containsObject:serverCertificateData]) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] cancelAuthenticationChallenge:challenge]; - } - - break; + + break; + } + case AFSSLPinningModeCertificate: { + SecCertificateRef serverCertificate = SecTrustGetCertificateAtIndex(serverTrust, 0); + NSData *serverCertificateData = (__bridge_transfer NSData *)SecCertificateCopyData(serverCertificate); + + if ([[[self class] pinnedCertificates] containsObject:serverCertificateData]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; } - case AFSSLPinningModeNone: { + + break; + } + case AFSSLPinningModeNone: { #ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; +#else + SecTrustResultType result = 0; + OSStatus status = SecTrustEvaluate(serverTrust, &result); + NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); + + if (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed) { NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; -#else - SecTrustResultType result = 0; - OSStatus status = SecTrustEvaluate(serverTrust, &result); - NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); - - if (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] cancelAuthenticationChallenge:challenge]; - } -#endif - break; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; } +#endif + break; } } + } } #endif From 5b633898b3c035fcc1761eaa10d7263cfa20f1d1 Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Sat, 6 Apr 2013 11:33:29 -0500 Subject: [PATCH 0143/1434] Clean up --- AFNetworking/AFURLConnectionOperation.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 0ecbdb8cc0..f7dd75c6cd 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -222,8 +222,7 @@ + (NSArray *)pinnedPublicKeys { status = SecTrustEvaluate(allowedTrust, &result); NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); - SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust); - + SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust); NSCParameterAssert(allowedPublicKey); [publicKeys addObject:(__bridge_transfer id)allowedPublicKey]; From 7207f2f19f6f93a549432e1b5316bccc74cee2d8 Mon Sep 17 00:00:00 2001 From: "@scutdavy" Date: Sat, 6 Apr 2013 20:06:15 +0200 Subject: [PATCH 0144/1434] Using indexesOfObjectsPassingTest to calculate numberOfFinishedOperations in -enqueueBatchOfHTTPRequestOperations: Signed-off-by: Mattt Thompson --- AFNetworking/AFHTTPClient.m | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index f349796c43..47a01199aa 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -605,12 +605,9 @@ - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations originalCompletionBlock(); } - NSUInteger numberOfFinishedOperations = 0; - for (NSOperation *operation in operations) { - if (operation.isFinished) { - numberOfFinishedOperations++; - } - } + NSInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger idx, BOOL *stop) { + return [op isCancelled]; + }] count]; if (progressBlock) { progressBlock(numberOfFinishedOperations, [operations count]); From 48398eb0acae85299159598bcae6501a43c1338b Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sat, 6 Apr 2013 20:09:23 +0200 Subject: [PATCH 0145/1434] Adding __unused to block paramters --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 47a01199aa..1d8c66373c 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -605,7 +605,7 @@ - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations originalCompletionBlock(); } - NSInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger idx, BOOL *stop) { + NSInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger __unused idx, BOOL __unused *stop) { return [op isCancelled]; }] count]; From 6d64ea1fa50f09f495bed1791d65fbd8e7c1a614 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sat, 6 Apr 2013 20:17:35 +0200 Subject: [PATCH 0146/1434] [Issue #888] Fixing property attribution build warning in AFHTTPClient body stream provider --- AFNetworking/AFHTTPClient.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 1d8c66373c..f38c30752f 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -761,7 +761,7 @@ @interface AFHTTPBodyPart : NSObject @property (nonatomic, strong) NSDictionary *headers; @property (nonatomic, strong) id body; @property (nonatomic, assign) unsigned long long bodyContentLength; -@property (nonatomic, readonly) NSInputStream *inputStream; +@property (nonatomic, strong) NSInputStream *inputStream; @property (nonatomic, assign) BOOL hasInitialBoundary; @property (nonatomic, assign) BOOL hasFinalBoundary; @@ -776,7 +776,7 @@ - (NSInteger)read:(uint8_t *)buffer @interface AFMultipartBodyStreamProvider : NSObject @property (nonatomic, assign) NSUInteger bufferLength; @property (nonatomic, assign) NSTimeInterval delay; -@property (nonatomic, readonly) NSInputStream *inputStream; +@property (nonatomic, strong) NSInputStream *inputStream; @property (nonatomic, readonly) unsigned long long contentLength; @property (nonatomic, readonly, getter = isEmpty) BOOL empty; @@ -968,7 +968,6 @@ @interface AFMultipartBodyStreamProvider () @property (nonatomic, strong) NSMutableArray *HTTPBodyParts; @property (nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; @property (nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; -@property (nonatomic, strong) NSInputStream *inputStream; @property (nonatomic, strong) NSOutputStream *outputStream; @property (nonatomic, strong) NSMutableData *buffer; @end From c8e420990efc80a1eba059f9c34fab0023efdcfc Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Sat, 6 Apr 2013 15:02:57 -0500 Subject: [PATCH 0147/1434] Added guard around adding a NULL object to an array --- AFNetworking/AFURLConnectionOperation.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index f7dd75c6cd..7ddc96b43f 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -224,7 +224,8 @@ + (NSArray *)pinnedPublicKeys { SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust); NSCParameterAssert(allowedPublicKey); - [publicKeys addObject:(__bridge_transfer id)allowedPublicKey]; + if(allowedPublicKey!=NULL) + [publicKeys addObject:(__bridge_transfer id)allowedPublicKey]; CFRelease(allowedTrust); CFRelease(policy); From 158db930ff0183048e203eabad6ad8c45227e72a Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Sat, 6 Apr 2013 15:46:50 -0500 Subject: [PATCH 0148/1434] Revert "Added guard around adding a NULL object to an array" This reverts commit c8e420990efc80a1eba059f9c34fab0023efdcfc. --- AFNetworking/AFURLConnectionOperation.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 7ddc96b43f..f7dd75c6cd 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -224,8 +224,7 @@ + (NSArray *)pinnedPublicKeys { SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust); NSCParameterAssert(allowedPublicKey); - if(allowedPublicKey!=NULL) - [publicKeys addObject:(__bridge_transfer id)allowedPublicKey]; + [publicKeys addObject:(__bridge_transfer id)allowedPublicKey]; CFRelease(allowedTrust); CFRelease(policy); From 8b2d01a503beb987fb6e11ab23c5d58bc6197cde Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Sun, 7 Apr 2013 08:29:29 +0200 Subject: [PATCH 0149/1434] Fixes SecTrustCreateWithCertificates expecting an array as first argument. --- AFNetworking/AFURLConnectionOperation.m | 117 ++++++++++++------------ 1 file changed, 61 insertions(+), 56 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index ae1bea93f2..ac1ca7e673 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -174,7 +174,7 @@ + (NSThread *)networkRequestThread { _networkRequestThread = [[NSThread alloc] initWithTarget:self selector:@selector(networkRequestThreadEntryPoint:) object:nil]; [_networkRequestThread start]; }); - + return _networkRequestThread; } @@ -185,7 +185,7 @@ + (NSArray *)pinnedCertificates { dispatch_once(&onceToken, ^{ NSBundle *bundle = [NSBundle bundleForClass:[self class]]; NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; - + NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]]; for (NSString *path in paths) { NSData *certificateData = [NSData dataWithContentsOfFile:path]; @@ -194,7 +194,7 @@ + (NSArray *)pinnedCertificates { _pinnedCertificates = [[NSArray alloc] initWithArray:certificates]; }); - + return _pinnedCertificates; } @@ -208,7 +208,7 @@ + (NSArray *)pinnedPublicKeys { for (NSData *data in pinnedCertificates) { SecCertificateRef allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)data); NSCParameterAssert(allowedCertificate); - + SecCertificateRef allowedCertificates[] = {allowedCertificate}; CFArrayRef certificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); @@ -219,13 +219,13 @@ + (NSArray *)pinnedPublicKeys { SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust); [publicKeys addObject:(__bridge_transfer id)allowedPublicKey]; - + CFRelease(allowedTrust); CFRelease(policy); CFRelease(certificates); CFRelease(allowedCertificate); } - + _pinnedPublicKeys = [[NSArray alloc] initWithArray:publicKeys]; }); @@ -238,20 +238,20 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest { if (!self) { return nil; } - + self.lock = [[NSRecursiveLock alloc] init]; self.lock.name = kAFNetworkingLockName; - + self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes]; - + self.request = urlRequest; - + self.shouldUseCredentialStorage = YES; - + self.outputStream = [NSOutputStream outputStreamToMemory]; - + self.state = AFOperationReadyState; - + return self; } @@ -260,7 +260,7 @@ - (void)dealloc { [_outputStream close]; _outputStream = nil; } - + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) if (_backgroundTaskIdentifier) { [[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier]; @@ -281,7 +281,7 @@ - (void)setCompletionBlock:(void (^)(void))block { __weak __typeof(&*self)weakSelf = self; [super setCompletionBlock:^ { __strong __typeof(&*weakSelf)strongSelf = weakSelf; - + block(); [strongSelf setCompletionBlock:nil]; }]; @@ -305,7 +305,7 @@ - (void)setOutputStream:(NSOutputStream *)outputStream { if (outputStream == _outputStream) { return; } - + [self willChangeValueForKey:@"outputStream"]; if (_outputStream) { [_outputStream close]; @@ -322,14 +322,14 @@ - (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))ha __weak __typeof(&*self)weakSelf = self; self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{ __strong __typeof(&*weakSelf)strongSelf = weakSelf; - + if (handler) { handler(); } - + if (strongSelf) { [strongSelf cancel]; - + [application endBackgroundTask:strongSelf.backgroundTaskIdentifier]; strongSelf.backgroundTaskIdentifier = UIBackgroundTaskInvalid; } @@ -386,7 +386,7 @@ - (NSString *)responseString { self.responseString = [[NSString alloc] initWithData:self.responseData encoding:self.responseStringEncoding]; } [self.lock unlock]; - + return _responseString; } @@ -400,11 +400,11 @@ - (NSStringEncoding)responseStringEncoding { stringEncoding = CFStringConvertEncodingToNSStringEncoding(IANAEncoding); } } - + self.responseStringEncoding = stringEncoding; } [self.lock unlock]; - + return _responseStringEncoding; } @@ -412,20 +412,20 @@ - (void)pause { if ([self isPaused] || [self isFinished] || [self isCancelled]) { return; } - + [self.lock lock]; - + if ([self isExecuting]) { [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - + dispatch_async(dispatch_get_main_queue(), ^{ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; }); } - + self.state = AFOperationPausedState; - + [self.lock unlock]; } @@ -437,10 +437,10 @@ - (void)resume { if (![self isPaused]) { return; } - + [self.lock lock]; self.state = AFOperationReadyState; - + [self start]; [self.lock unlock]; } @@ -467,7 +467,7 @@ - (void)start { [self.lock lock]; if ([self isReady]) { self.state = AFOperationExecutingState; - + [self performSelector:@selector(operationDidStart) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; } [self.lock unlock]; @@ -512,7 +512,7 @@ - (void)cancel { _cancelled = YES; [super cancel]; [self didChangeValueForKey:@"isCancelled"]; - + // Cancel the connection on the thread it runs on to prevent race conditions [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; } @@ -525,10 +525,10 @@ - (void)cancelConnection { userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; } self.error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; - + if (self.connection) { [self.connection cancel]; - + // Manually send this delegate message since `[self.connection cancel]` causes the connection to never send another message to its delegate [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.error]; } @@ -553,13 +553,18 @@ - (void)connection:(NSURLConnection *)connection if (self.SSLPinningMode == AFSSLPinningModeCertificate) { [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; } else if (self.SSLPinningMode == AFSSLPinningModePublicKey) { + SecCertificateRef someCertificates[] = {certificate}; + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); + SecTrustRef trust = NULL; - OSStatus status = SecTrustCreateWithCertificates(certificate, policy, &trust); + + OSStatus status = SecTrustCreateWithCertificates(certificates, policy, &trust); NSAssert(status == noErr, @"SecTrustCreateWithCertificates error: %ld", (long int)status); [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; CFRelease(trust); + CFRelease(certificates); } } @@ -622,7 +627,7 @@ - (BOOL)connection:(NSURLConnection *)connection return YES; } #endif - + if (self.authenticationAgainstProtectionSpace) { return self.authenticationAgainstProtectionSpace(connection, protectionSpace); } else if ([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust] || [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodClientCertificate]) { @@ -641,16 +646,16 @@ - (void)connection:(NSURLConnection *)connection return; } #endif - + if (self.authenticationChallenge) { self.authenticationChallenge(connection, challenge); } else { if ([challenge previousFailureCount] == 0) { NSURLCredential *credential = nil; - + NSString *user = [[self.request URL] user]; NSString *password = [[self.request URL] password]; - + if (user && password) { credential = [NSURLCredential credentialWithUser:user password:password persistence:NSURLCredentialPersistenceNone]; } else if (user) { @@ -658,11 +663,11 @@ - (void)connection:(NSURLConnection *)connection } else { credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]]; } - + if (!credential) { credential = self.credential; } - + if (credential) { [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; } else { @@ -684,7 +689,7 @@ - (NSInputStream *)connection:(NSURLConnection __unused *)connection if ([request.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { return [request.HTTPBodyStream copy]; } - + return nil; } @@ -715,7 +720,7 @@ - (void)connection:(NSURLConnection __unused *)connection didReceiveResponse:(NSURLResponse *)response { self.response = response; - + [self.outputStream open]; } @@ -738,11 +743,11 @@ - (void)connection:(NSURLConnection __unused *)connection - (void)connectionDidFinishLoading:(NSURLConnection __unused *)connection { self.responseData = [self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey]; - + [self.outputStream close]; - + [self finish]; - + self.connection = nil; } @@ -750,11 +755,11 @@ - (void)connection:(NSURLConnection __unused *)connection didFailWithError:(NSError *)error { self.error = error; - + [self.outputStream close]; - + [self finish]; - + self.connection = nil; } @@ -767,7 +772,7 @@ - (NSCachedURLResponse *)connection:(NSURLConnection *)connection if ([self isCancelled]) { return nil; } - + return cachedResponse; } } @@ -776,27 +781,27 @@ - (NSCachedURLResponse *)connection:(NSURLConnection *)connection - (id)initWithCoder:(NSCoder *)aDecoder { NSURLRequest *request = [aDecoder decodeObjectForKey:@"request"]; - + self = [self initWithRequest:request]; if (!self) { return nil; } - + self.state = (AFOperationState)[aDecoder decodeIntegerForKey:@"state"]; self.cancelled = [aDecoder decodeBoolForKey:@"isCancelled"]; self.response = [aDecoder decodeObjectForKey:@"response"]; self.error = [aDecoder decodeObjectForKey:@"error"]; self.responseData = [aDecoder decodeObjectForKey:@"responseData"]; self.totalBytesRead = [[aDecoder decodeObjectForKey:@"totalBytesRead"] longLongValue]; - + return self; } - (void)encodeWithCoder:(NSCoder *)aCoder { [self pause]; - + [aCoder encodeObject:self.request forKey:@"request"]; - + switch (self.state) { case AFOperationExecutingState: case AFOperationPausedState: @@ -806,7 +811,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeInteger:self.state forKey:@"state"]; break; } - + [aCoder encodeBool:[self isCancelled] forKey:@"isCancelled"]; [aCoder encodeObject:self.response forKey:@"response"]; [aCoder encodeObject:self.error forKey:@"error"]; @@ -818,7 +823,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { - (id)copyWithZone:(NSZone *)zone { AFURLConnectionOperation *operation = [(AFURLConnectionOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request]; - + operation.uploadProgress = self.uploadProgress; operation.downloadProgress = self.downloadProgress; operation.authenticationAgainstProtectionSpace = self.authenticationAgainstProtectionSpace; From ecbe8166cd8e6f15280b6d03fb75d95a16c4f2a8 Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Mon, 8 Apr 2013 14:04:08 +0200 Subject: [PATCH 0150/1434] Now using errSecSuccess instead of noErr for Security frameworks OSStatus. --- AFNetworking/AFURLConnectionOperation.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index f854488e9d..69c8870e5a 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -216,11 +216,11 @@ + (NSArray *)pinnedPublicKeys { SecPolicyRef policy = SecPolicyCreateBasicX509(); SecTrustRef allowedTrust = NULL; OSStatus status = SecTrustCreateWithCertificates(certificates, policy, &allowedTrust); - NSAssert(status == noErr, @"SecTrustCreateWithCertificates error: %ld", (long int)status); + NSAssert(status == errSecSuccess, @"SecTrustCreateWithCertificates error: %ld", (long int)status); SecTrustResultType result = 0; status = SecTrustEvaluate(allowedTrust, &result); - NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); + NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status); SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust); NSCParameterAssert(allowedPublicKey); @@ -565,11 +565,11 @@ - (void)connection:(NSURLConnection *)connection SecTrustRef trust = NULL; OSStatus status = SecTrustCreateWithCertificates(certificates, policy, &trust); - NSAssert(status == noErr, @"SecTrustCreateWithCertificates error: %ld", (long int)status); + NSAssert(status == errSecSuccess, @"SecTrustCreateWithCertificates error: %ld", (long int)status); SecTrustResultType result; status = SecTrustEvaluate(trust, &result); - NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); + NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status); [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; @@ -612,7 +612,7 @@ - (void)connection:(NSURLConnection *)connection #else SecTrustResultType result = 0; OSStatus status = SecTrustEvaluate(serverTrust, &result); - NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); + NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status); if (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed) { NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; From ae6b3bb36852764774609819aed6049a284ca025 Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Mon, 8 Apr 2013 14:04:43 +0200 Subject: [PATCH 0151/1434] Now using NSParameterAssert instead of NSCParameterAssert. --- AFNetworking/AFURLConnectionOperation.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 69c8870e5a..9e24e9fbab 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -208,7 +208,7 @@ + (NSArray *)pinnedPublicKeys { for (NSData *data in pinnedCertificates) { SecCertificateRef allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)data); - NSCParameterAssert(allowedCertificate); + NSParameterAssert(allowedCertificate); SecCertificateRef allowedCertificates[] = {allowedCertificate}; CFArrayRef certificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); @@ -223,7 +223,7 @@ + (NSArray *)pinnedPublicKeys { NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status); SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust); - NSCParameterAssert(allowedPublicKey); + NSParameterAssert(allowedPublicKey); [publicKeys addObject:(__bridge_transfer id)allowedPublicKey]; CFRelease(allowedTrust); From fa9fa6e0d459ec1d4d149010ab1b92df9066c3ee Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Tue, 9 Apr 2013 08:47:26 -0500 Subject: [PATCH 0152/1434] Fixed if/else logic --- AFNetworking/AFURLConnectionOperation.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 5e9d679a44..3f4df0257a 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -614,13 +614,11 @@ - (void)connection:(NSURLConnection *)connection if(self.allowInvalidSSLCertificate == YES){ NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] cancelAuthenticationChallenge:challenge]; } else { SecTrustResultType result = 0; OSStatus status = SecTrustEvaluate(serverTrust, &result); - NSAssert(status == noErr, @"SecTrustEvaluate error: %ld", (long int)status); + NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status); if (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed) { NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; From 8d075dde30dc8549d8c55ec34d4b24a2f9fe14d4 Mon Sep 17 00:00:00 2001 From: Rune Madsen Date: Wed, 10 Apr 2013 14:47:36 -0400 Subject: [PATCH 0153/1434] Check for finished operations in order to increments the `numberOfFinishedOperations` count --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index f38c30752f..c06640b43f 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -606,7 +606,7 @@ - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations } NSInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger __unused idx, BOOL __unused *stop) { - return [op isCancelled]; + return [op isFinished]; }] count]; if (progressBlock) { From ae4981eef163d563e147117c5ea04dfd350e8dce Mon Sep 17 00:00:00 2001 From: Kra Larivain Date: Mon, 15 Apr 2013 17:45:36 -0700 Subject: [PATCH 0154/1434] - fix for unescaped brackets in params values --- AFNetworking/AFHTTPClient.m | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index c06640b43f..4bd5d6b6fd 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -80,11 +80,13 @@ return [[NSString alloc] initWithData:mutableData encoding:NSASCIIStringEncoding]; } -static NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { +static NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding, BOOL isValue) { static NSString * const kAFCharactersToBeEscaped = @":/?&=;+!@#$()~',*"; - static NSString * const kAFCharactersToLeaveUnescaped = @"[]."; - - return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, (__bridge CFStringRef)kAFCharactersToLeaveUnescaped, (__bridge CFStringRef)kAFCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)); + static NSString * const kAFParamNameCharactersToLeaveUnescaped = @"[]."; + static NSString * const kAFParamValueCharactersToLeaveUnescaped = @""; + + NSString *unescaped = isValue ? kAFParamValueCharactersToLeaveUnescaped : kAFParamNameCharactersToLeaveUnescaped; + return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, (__bridge CFStringRef)unescaped, (__bridge CFStringRef)kAFCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)); } #pragma mark - @@ -116,9 +118,9 @@ - (id)initWithField:(id)field value:(id)value { - (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding { if (!self.value || [self.value isEqual:[NSNull null]]) { - return AFPercentEscapedQueryStringPairMemberFromStringWithEncoding([self.field description], stringEncoding); + return AFPercentEscapedQueryStringPairMemberFromStringWithEncoding([self.field description], stringEncoding, NO); } else { - return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedQueryStringPairMemberFromStringWithEncoding([self.field description], stringEncoding), AFPercentEscapedQueryStringPairMemberFromStringWithEncoding([self.value description], stringEncoding)]; + return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedQueryStringPairMemberFromStringWithEncoding([self.field description], stringEncoding, NO), AFPercentEscapedQueryStringPairMemberFromStringWithEncoding([self.value description], stringEncoding, YES)]; } } From 3c6bec4207524c295908a573b7ed5663298ec885 Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Tue, 16 Apr 2013 10:31:41 +0300 Subject: [PATCH 0155/1434] Added runtime check to disable pinning in the example Signed-off-by: Mattt Thompson --- Example/Classes/AFAppDotNetAPIClient.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Example/Classes/AFAppDotNetAPIClient.m b/Example/Classes/AFAppDotNetAPIClient.m index 7859d9094f..213a71ab1a 100644 --- a/Example/Classes/AFAppDotNetAPIClient.m +++ b/Example/Classes/AFAppDotNetAPIClient.m @@ -48,8 +48,11 @@ - (id)initWithBaseURL:(NSURL *)url { // Accept HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1 [self setDefaultHeader:@"Accept" value:@"application/json"]; - - [self setDefaultSSLPinningMode:AFSSLPinningModePublicKey]; + + // By default, the example ships with SSL pinning enabled for the app.net API pinned against the public key of adn.cer file included with the example. In order to make it easier for developers who are new to AFNetworking, SSL pinning is automatically disabled if the base URL has been changed. This will allow developers to hack around with the example, without getting tripped up by SSL pinning. + if ([[url scheme] isEqualToString:@"https"] && [[url host] isEqualToString:@"alpha-api.app.net"]) { + [self setDefaultSSLPinningMode:AFSSLPinningModePublicKey]; + } return self; } From 472ba1c66aac6065acc01c7dbf525508566e0c24 Mon Sep 17 00:00:00 2001 From: Jean-Francois Morin Date: Tue, 16 Apr 2013 11:00:26 +0300 Subject: [PATCH 0156/1434] Replace NSData by NSUInteger in connection:didReceiveData: Signed-off-by: Mattt Thompson --- AFNetworking/AFURLConnectionOperation.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 9e24e9fbab..382b01ee33 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -738,16 +738,17 @@ - (void)connection:(NSURLConnection __unused *)connection - (void)connection:(NSURLConnection __unused *)connection didReceiveData:(NSData *)data { + NSUInteger length = [data length]; if ([self.outputStream hasSpaceAvailable]) { const uint8_t *dataBuffer = (uint8_t *) [data bytes]; - [self.outputStream write:&dataBuffer[0] maxLength:[data length]]; + [self.outputStream write:&dataBuffer[0] maxLength:length]; } dispatch_async(dispatch_get_main_queue(), ^{ - self.totalBytesRead += [data length]; + self.totalBytesRead += length; if (self.downloadProgress) { - self.downloadProgress([data length], self.totalBytesRead, self.response.expectedContentLength); + self.downloadProgress(length, self.totalBytesRead, self.response.expectedContentLength); } }); } From 174bc47c840eda63c1bd3732eaee3f6c9fad1b76 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 17 Apr 2013 18:28:08 +0200 Subject: [PATCH 0157/1434] Minor refactoring / renaming / copy edits --- AFNetworking/AFURLConnectionOperation.h | 6 ++++-- AFNetworking/AFURLConnectionOperation.m | 12 +++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index aba6002fd9..523f5e6fc0 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -128,9 +128,11 @@ NSCoding, NSCopying> @property (readonly, nonatomic, strong) NSError *error; /** - The flag to determine if the connection should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to YES for backwards compatibility support. Otherwise, this property defaults to NO. + Whether the connection should accept an invalid SSL certificate. + + If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to `YES` for backwards compatibility. Otherwise, this property defaults to `NO`. */ -@property (nonatomic,assign) BOOL allowInvalidSSLCertificate; +@property (nonatomic, assign) BOOL allowInvalidSSLCertificate; ///---------------------------- /// @name Getting Response Data diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 82ca1634db..395cd1a90b 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -257,8 +257,8 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest { self.outputStream = [NSOutputStream outputStreamToMemory]; self.state = AFOperationReadyState; - - //This ifdef has been added for backwards compatibility purposes + + // #ifdef included for backwards-compatibility #ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ self.allowInvalidSSLCertificate = YES; #endif @@ -611,11 +611,10 @@ - (void)connection:(NSURLConnection *)connection break; } case AFSSLPinningModeNone: { - if(self.allowInvalidSSLCertificate == YES){ + if (self.allowInvalidSSLCertificate){ NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } - else { + } else { SecTrustResultType result = 0; OSStatus status = SecTrustEvaluate(serverTrust, &result); NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status); @@ -656,13 +655,12 @@ - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { - if(self.allowInvalidSSLCertificate == YES + if (self.allowInvalidSSLCertificate && [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; return; } - if (self.authenticationChallenge) { self.authenticationChallenge(connection, challenge); } else { From 9cbc749d404d1705ac3383681edb2de8d2398f85 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 17 Apr 2013 18:38:44 +0200 Subject: [PATCH 0158/1434] Renaming allowInvalidSSLCertificate -> allowsInvalidSSLCertificate --- AFNetworking/AFHTTPClient.h | 6 ++++-- AFNetworking/AFHTTPClient.m | 6 +++--- AFNetworking/AFURLConnectionOperation.h | 6 +++--- AFNetworking/AFURLConnectionOperation.m | 14 +++++++------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 0ede582697..f866ab08de 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -146,9 +146,11 @@ typedef enum { #endif /** - The flag to determine if each `AFHTTPRequestOperation` that is created in `HTTPRequestOperationWithRequest` should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to YES for backwards compatibility support. Otherwise, this property defaults to NO. + Whether each `AFHTTPRequestOperation` that is created in `HTTPRequestOperationWithRequest` should accept an invalid SSL certificate. + + If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to `YES` for backwards compatibility. Otherwise, this property defaults to `NO`. */ -@property (nonatomic,assign) BOOL allowInvalidSSLCertificate; +@property (nonatomic,assign) BOOL allowsInvalidSSLCertificate; ///--------------------------------------------- /// @name Creating and Initializing HTTP Clients diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 35cdcd71c6..b7458476e2 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -263,9 +263,9 @@ - (id)initWithBaseURL:(NSURL *)url { self.operationQueue = [[NSOperationQueue alloc] init]; [self.operationQueue setMaxConcurrentOperationCount:NSOperationQueueDefaultMaxConcurrentOperationCount]; - //This ifdef has been added for backwards compatibility purposes + // #ifdef included for backwards-compatibility #ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ - self.allowInvalidSSLCertificate = YES; + self.allowsInvalidSSLCertificate = YES; #endif return self; @@ -541,7 +541,7 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ operation.SSLPinningMode = self.defaultSSLPinningMode; #endif - operation.allowInvalidSSLCertificate = self.allowInvalidSSLCertificate; + operation.allowsInvalidSSLCertificate = self.allowsInvalidSSLCertificate; return operation; } diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 523f5e6fc0..6898e4c9ce 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -132,7 +132,7 @@ NSCoding, NSCopying> If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to `YES` for backwards compatibility. Otherwise, this property defaults to `NO`. */ -@property (nonatomic, assign) BOOL allowInvalidSSLCertificate; +@property (nonatomic, assign) BOOL allowsInvalidSSLCertificate; ///---------------------------- /// @name Getting Response Data @@ -287,7 +287,7 @@ NSCoding, NSCopying> @param block A block object to be executed to determine whether the connection should be able to respond to a protection space's form of authentication. The block has a `BOOL` return type and takes two arguments: the URL connection object, and the protection space to authenticate against. - If `allowInvalidSSLCertificate` is set to YES, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. + If `allowsInvalidSSLCertificate` is set to YES, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. */ - (void)setAuthenticationAgainstProtectionSpaceBlock:(BOOL (^)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace))block; @@ -296,7 +296,7 @@ NSCoding, NSCopying> @param block A block object to be executed when the connection must authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. - If `allowInvalidSSLCertificate` is set to YES, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. + If `allowsInvalidSSLCertificate` is set to YES, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. */ - (void)setAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 395cd1a90b..f3c0020849 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -260,7 +260,7 @@ - (id)initWithRequest:(NSURLRequest *)urlRequest { // #ifdef included for backwards-compatibility #ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ - self.allowInvalidSSLCertificate = YES; + self.allowsInvalidSSLCertificate = YES; #endif return self; @@ -611,7 +611,7 @@ - (void)connection:(NSURLConnection *)connection break; } case AFSSLPinningModeNone: { - if (self.allowInvalidSSLCertificate){ + if (self.allowsInvalidSSLCertificate){ NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; } else { @@ -637,7 +637,7 @@ - (void)connection:(NSURLConnection *)connection - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { - if(self.allowInvalidSSLCertificate == YES && + if(self.allowsInvalidSSLCertificate == YES && [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { return YES; } @@ -655,7 +655,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { - if (self.allowInvalidSSLCertificate + if (self.allowsInvalidSSLCertificate && [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; return; @@ -808,7 +808,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder { self.error = [aDecoder decodeObjectForKey:@"error"]; self.responseData = [aDecoder decodeObjectForKey:@"responseData"]; self.totalBytesRead = [[aDecoder decodeObjectForKey:@"totalBytesRead"] longLongValue]; - self.allowInvalidSSLCertificate = [[aDecoder decodeObjectForKey:@"allowInvalidSSLCertificate"] boolValue]; + self.allowsInvalidSSLCertificate = [[aDecoder decodeObjectForKey:@"allowsInvalidSSLCertificate"] boolValue]; return self; } @@ -833,7 +833,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.error forKey:@"error"]; [aCoder encodeObject:self.responseData forKey:@"responseData"]; [aCoder encodeObject:[NSNumber numberWithLongLong:self.totalBytesRead] forKey:@"totalBytesRead"]; - [aCoder encodeObject:[NSNumber numberWithBool:self.allowInvalidSSLCertificate] forKey:@"allowInvalidSSLCertificate"]; + [aCoder encodeObject:[NSNumber numberWithBool:self.allowsInvalidSSLCertificate] forKey:@"allowsInvalidSSLCertificate"]; } #pragma mark - NSCopying @@ -847,7 +847,7 @@ - (id)copyWithZone:(NSZone *)zone { operation.authenticationChallenge = self.authenticationChallenge; operation.cacheResponse = self.cacheResponse; operation.redirectResponse = self.redirectResponse; - operation.allowInvalidSSLCertificate = self.allowInvalidSSLCertificate; + operation.allowsInvalidSSLCertificate = self.allowsInvalidSSLCertificate; return operation; } From b838dd85c13c2668163919e1a72b2699e088a190 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 17 Apr 2013 18:39:50 +0200 Subject: [PATCH 0159/1434] Minor reformatting --- AFNetworking/AFHTTPClient.h | 2 +- AFNetworking/AFHTTPClient.m | 2 +- AFNetworking/AFURLConnectionOperation.m | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index f866ab08de..fa6f51d962 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -150,7 +150,7 @@ typedef enum { If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to `YES` for backwards compatibility. Otherwise, this property defaults to `NO`. */ -@property (nonatomic,assign) BOOL allowsInvalidSSLCertificate; +@property (nonatomic, assign) BOOL allowsInvalidSSLCertificate; ///--------------------------------------------- /// @name Creating and Initializing HTTP Clients diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index b7458476e2..e23f2a05a7 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1102,7 +1102,7 @@ - (void)handleOutputStreamSpaceAvailable { [_buffer setLength:numberOfBytesRead]; - if(numberOfBytesRead == 0) { + if (numberOfBytesRead == 0) { self.currentHTTPBodyPart = nil; } diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index f3c0020849..41034a17b6 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -637,7 +637,7 @@ - (void)connection:(NSURLConnection *)connection - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { - if(self.allowsInvalidSSLCertificate == YES && + if (self.allowsInvalidSSLCertificate && [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { return YES; } From c28434ce71eb07b8a053400c41ec9d5e76c29b1c Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 17 Apr 2013 18:42:34 +0200 Subject: [PATCH 0160/1434] Fixing error in documentation about defaultSSLPinningMode Minor copy editing in documentation --- AFNetworking/AFHTTPClient.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index fa6f51d962..38c8ca2d58 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -139,14 +139,14 @@ typedef enum { #endif /** - Default SSL pinning mode for each `AFHTTPRequestOperation` which will be enqueued with `enqueueHTTPRequestOperation:`. + Default SSL pinning mode for each `AFHTTPRequestOperation` created by `HTTPRequestOperationWithRequest:success:failure:`. */ #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ @property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode defaultSSLPinningMode; #endif /** - Whether each `AFHTTPRequestOperation` that is created in `HTTPRequestOperationWithRequest` should accept an invalid SSL certificate. + Whether each `AFHTTPRequestOperation` created by `HTTPRequestOperationWithRequest:success:failure:` should accept an invalid SSL certificate. If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to `YES` for backwards compatibility. Otherwise, this property defaults to `NO`. */ From 215a32e23c0d605983779d12d5026ced5cc2bf28 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 18 Apr 2013 07:47:53 +0200 Subject: [PATCH 0161/1434] Bumping version to 1.2.1 Updating CHANGES for 1.2.1 --- AFNetworking.podspec | 4 ++-- CHANGES | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/AFNetworking.podspec b/AFNetworking.podspec index c3a8dbbc8d..e6ee683057 100644 --- a/AFNetworking.podspec +++ b/AFNetworking.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = 'AFNetworking' - s.version = '1.2.0' + s.version = '1.2.1' s.license = 'MIT' s.summary = 'A delightful iOS and OS X networking framework.' s.homepage = 'https://github.com/AFNetworking/AFNetworking' s.authors = { 'Mattt Thompson' => 'm@mattt.me', 'Scott Raymond' => 'sco@gowalla.com' } - s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => '1.2.0' } + s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => '1.2.1' } s.source_files = 'AFNetworking' s.requires_arc = true diff --git a/CHANGES b/CHANGES index 0767b58e2a..a8ba027c6e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,42 @@ += 1.2.1 (2013-04-18) + + * Add `allowsInvalidSSLCertificate` property to `AFURLConnectionOperation` and +`AFHTTPClient`, replacing `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` macro +(Kevin Harwood) + + * Add SSL pinning mode to example project (Kevin Harwood) + + * Add name to AFNetworking network thread (Peter Steinberger) + + * Change pinned certificates to trust all derived certificates (Oliver +Letterer) + + * Fix documentation about SSL pinning (Kevin Harwood, Mattt Thompson) + + * Fix certain enumerated loops to use fast enumeration, resulting in better +performance (Oliver Letterer) + + * Fix macro to work correctly under Mac OS X 10.7 and iOS 4 SDK (Paul Melnikow) + + * Fix documentation, removing unsupported `@discussion` tags (Michele Titolo) + + * Fix `SecTrustCreateWithCertificates` expecting an array as first argument +(Oliver Letterer) + + * Fix to use `errSecSuccess` instead of `noErr` for Security frameworks +OSStatus (Oliver Letterer) + + * Fix `AFImageRequestOperation` to use `[self alloc]` instead of explicit +class, which allows for subclassing (James Clarke) + + * Fix for `numberOfFinishedOperations` calculations (Rune Madsen) + + * Fix calculation of data length in `-connection:didReceiveData:` +(Jean-Francois Morin) + + * Fix to encode JSON only with UTF-8, following recommendation of +`NSJSONSerialiation` (Sebastian Utz) + = 1.2.0 (2013-03-24) * Add `SSLPinningMode` property to `AFHTTPClient` (Oliver Letterer, Kevin From 6a6862c43b735f3b9d12a273d7774c5a68bf7532 Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Sun, 21 Apr 2013 18:07:46 +0200 Subject: [PATCH 0162/1434] Workaround for #907. --- AFNetworking/AFHTTPClient.m | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index e23f2a05a7..683326fb47 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1114,8 +1114,21 @@ - (void)handleOutputStreamSpaceAvailable { } - (void)close { - [_outputStream close]; - _outputStream.delegate = nil; + NSOutputStream *outputStream = self.outputStream; + + [outputStream close]; + outputStream.delegate = nil; + + /* + Workaround for a race condition in CFStream _CFStreamCopyRunLoopsAndModes. This outputstream needs to be retained just a little longer. + + See: https://github.com/AFNetworking/AFNetworking/issues/907 + */ + double delayInSeconds = 2.0; + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); + dispatch_after(popTime, dispatch_get_main_queue(), ^{ + outputStream.delegate = nil; + }); _self = nil; } From a0cc0203579abdd8e34b073f1f430e5326a3dd3e Mon Sep 17 00:00:00 2001 From: Dave Anderson Date: Mon, 22 Apr 2013 16:21:04 -0600 Subject: [PATCH 0163/1434] A GET request for file:///path/to/file URLs has a self.response that does not respond to allHeaderFields because it is an NSURLResponse not an NSHTTPURLResponse --- AFNetworking/AFHTTPRequestOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 98aa07cd1f..80b61f82e3 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -165,7 +165,7 @@ - (NSError *)error { - (NSStringEncoding)responseStringEncoding { // When no explicit charset parameter is provided by the sender, media subtypes of the "text" type are defined to have a default charset value of "ISO-8859-1" when received via HTTP. Data in character sets other than "ISO-8859-1" or its subsets MUST be labeled with an appropriate charset value. // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.4.1 - if (self.response && !self.response.textEncodingName && self.responseData) { + if (self.response && !self.response.textEncodingName && self.responseData && [self.response respondsToSelector:@selector(allHeaderFields)]) { NSString *type = nil; AFGetMediaTypeAndSubtypeWithString([[self.response allHeaderFields] valueForKey:@"Content-Type"], &type, nil); From fff8704a449f22f639b3df709d7bf298566529f1 Mon Sep 17 00:00:00 2001 From: Dave Keck Date: Tue, 23 Apr 2013 11:10:34 -1000 Subject: [PATCH 0164/1434] Fixing crasher in AFNetworkActivityIndicatorManager, due to unsafe calls to updateNetworkActivityIndicatorVisibilityDelayed from multiple threads. --- AFNetworking/AFNetworkActivityIndicatorManager.m | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.m b/AFNetworking/AFNetworkActivityIndicatorManager.m index b7e4256ff8..a000a14898 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.m +++ b/AFNetworking/AFNetworkActivityIndicatorManager.m @@ -105,7 +105,10 @@ - (void)setActivityCount:(NSInteger)activityCount { @synchronized(self) { _activityCount = activityCount; } - [self updateNetworkActivityIndicatorVisibilityDelayed]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateNetworkActivityIndicatorVisibilityDelayed]; + }); } - (void)incrementActivityCount { @@ -114,7 +117,10 @@ - (void)incrementActivityCount { _activityCount++; } [self didChangeValueForKey:@"activityCount"]; - [self updateNetworkActivityIndicatorVisibilityDelayed]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateNetworkActivityIndicatorVisibilityDelayed]; + }); } - (void)decrementActivityCount { @@ -123,7 +129,10 @@ - (void)decrementActivityCount { _activityCount = MAX(_activityCount - 1, 0); } [self didChangeValueForKey:@"activityCount"]; - [self updateNetworkActivityIndicatorVisibilityDelayed]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateNetworkActivityIndicatorVisibilityDelayed]; + }); } - (void)networkingOperationDidStart:(NSNotification *)notification { From cbfe5b72c6b4c4fdf62192aa130e70abe877c136 Mon Sep 17 00:00:00 2001 From: Henrik Hartz Date: Sun, 28 Apr 2013 11:19:09 +0200 Subject: [PATCH 0165/1434] Suppressed GNU expression and Enum assignment warnings from clang --- AFNetworking/AFHTTPClient.m | 17 ++++++++++++++++- AFNetworking/AFHTTPRequestOperation.m | 1 + AFNetworking/AFImageRequestOperation.m | 6 +++++- AFNetworking/AFJSONRequestOperation.m | 2 ++ .../AFNetworkActivityIndicatorManager.m | 3 +++ AFNetworking/AFPropertyListRequestOperation.m | 1 + AFNetworking/AFXMLRequestOperation.m | 1 + 7 files changed, 29 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index e23f2a05a7..bee9a4c5c3 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -247,13 +247,16 @@ - (id)initWithBaseURL:(NSURL *)url { *stop = q <= 0.5f; }]; [self setDefaultHeader:@"Accept-Language" value:[acceptLanguagesComponents componentsJoinedByString:@", "]]; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0f)]]; #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]]; #endif +#pragma clang diagnostic pop #ifdef _SYSTEMCONFIGURATION_H self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; @@ -464,7 +467,10 @@ - (NSMutableURLRequest *)requestWithMethod:(NSString *)method break; case AFJSONParameterEncoding:; [request setValue:[NSString stringWithFormat:@"application/json; charset=%@", charset] forHTTPHeaderField:@"Content-Type"]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wassign-enum" [request setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error]]; +#pragma clang diagnostic pop break; case AFPropertyListParameterEncoding:; [request setValue:[NSString stringWithFormat:@"application/x-plist; charset=%@", charset] forHTTPHeaderField:@"Content-Type"]; @@ -555,7 +561,10 @@ - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation { - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" NSString *pathToBeMatched = [[[self requestWithMethod:(method ?: @"GET") path:path parameters:nil] URL] path]; +#pragma clang diagnostic pop for (NSOperation *operation in [self.operationQueue operations]) { if (![operation isKindOfClass:[AFHTTPRequestOperation class]]) { @@ -605,7 +614,10 @@ - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations __weak __typeof(&*operation)weakOperation = operation; operation.completionBlock = ^{ __strong __typeof(&*weakOperation)strongOperation = weakOperation; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" dispatch_queue_t queue = strongOperation.successCallbackQueue ?: dispatch_get_main_queue(); +#pragma clang diagnostic pop dispatch_group_async(dispatchGroup, queue, ^{ if (originalCompletionBlock) { originalCompletionBlock(); @@ -1297,8 +1309,11 @@ - (NSInteger)readData:(NSData *)data intoBuffer:(uint8_t *)buffer maxLength:(NSUInteger)length { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length)); [data getBytes:buffer range:range]; +#pragma clang diagnostic pop _phaseReadOffset += range.length; diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 98aa07cd1f..772489ebf7 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -261,6 +261,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" self.completionBlock = ^{ if (self.error) { if (failure) { diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index cfac8d9250..d4119d2fe7 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -82,10 +82,12 @@ + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest if (imageProcessingBlock) { dispatch_async(image_request_operation_processing_queue(), ^(void) { UIImage *processedImage = imageProcessingBlock(image); - +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" dispatch_async(operation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) { success(operation.request, operation.response, processedImage); }); +#pragma clang diagnostic pop }); } else { success(operation.request, operation.response, image); @@ -203,6 +205,8 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" + self.completionBlock = ^ { dispatch_async(image_request_operation_processing_queue(), ^(void) { if (self.error) { diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index ac7423a1a0..0a39dee8b9 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -109,6 +109,8 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" + self.completionBlock = ^ { if (self.error) { if (failure) { diff --git a/AFNetworking/AFNetworkActivityIndicatorManager.m b/AFNetworking/AFNetworkActivityIndicatorManager.m index b7e4256ff8..810db1037c 100644 --- a/AFNetworking/AFNetworkActivityIndicatorManager.m +++ b/AFNetworking/AFNetworkActivityIndicatorManager.m @@ -120,7 +120,10 @@ - (void)incrementActivityCount { - (void)decrementActivityCount { [self willChangeValueForKey:@"activityCount"]; @synchronized(self) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" _activityCount = MAX(_activityCount - 1, 0); +#pragma clang diagnostic pop } [self didChangeValueForKey:@"activityCount"]; [self updateNetworkActivityIndicatorVisibilityDelayed]; diff --git a/AFNetworking/AFPropertyListRequestOperation.m b/AFNetworking/AFPropertyListRequestOperation.m index 4d6123b56d..370e12be8e 100644 --- a/AFNetworking/AFPropertyListRequestOperation.m +++ b/AFNetworking/AFPropertyListRequestOperation.m @@ -109,6 +109,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" self.completionBlock = ^ { if (self.error) { if (failure) { diff --git a/AFNetworking/AFXMLRequestOperation.m b/AFNetworking/AFXMLRequestOperation.m index 30a76b90ae..a97cd88478 100644 --- a/AFNetworking/AFXMLRequestOperation.m +++ b/AFNetworking/AFXMLRequestOperation.m @@ -141,6 +141,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" self.completionBlock = ^ { dispatch_async(xml_request_operation_processing_queue(), ^(void) { NSXMLParser *XMLParser = self.responseXMLParser; From 00901df325731001f31217f98e7cbb83f716c146 Mon Sep 17 00:00:00 2001 From: Yaron Inger Date: Sun, 28 Apr 2013 16:25:50 +0300 Subject: [PATCH 0166/1434] Add __unused to stream delegate parameter --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index e23f2a05a7..782aee273d 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -1061,7 +1061,7 @@ - (BOOL)isEmpty { #pragma mark - NSStreamDelegate -- (void)stream:(NSStream *)stream +- (void)stream:(NSStream __unused *)stream handleEvent:(NSStreamEvent)eventCode { if (eventCode & NSStreamEventHasSpaceAvailable) { From 05184b2769c0783d2a3308b871c4b657dee54952 Mon Sep 17 00:00:00 2001 From: Audun Holm Ellertsen Date: Mon, 29 Apr 2013 12:19:45 +0100 Subject: [PATCH 0167/1434] Adds explicit type casts where necessary for ObjC++ compilation --- AFNetworking/AFHTTPClient.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index e23f2a05a7..babe4bc5d4 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -693,7 +693,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder { } self.stringEncoding = [aDecoder decodeIntegerForKey:@"stringEncoding"]; - self.parameterEncoding = [aDecoder decodeIntegerForKey:@"parameterEncoding"]; + self.parameterEncoding = (AFHTTPClientParameterEncoding) [aDecoder decodeIntegerForKey:@"parameterEncoding"]; self.registeredHTTPOperationClassNames = [aDecoder decodeObjectForKey:@"registeredHTTPOperationClassNames"]; self.defaultHeaders = [aDecoder decodeObjectForKey:@"defaultHeaders"]; @@ -1072,7 +1072,7 @@ - (void)stream:(NSStream *)stream - (void)handleOutputStreamSpaceAvailable { while ([_outputStream hasSpaceAvailable]) { if ([_buffer length] > 0) { - NSInteger numberOfBytesWritten = [_outputStream write:[_buffer bytes] maxLength:[_buffer length]]; + NSInteger numberOfBytesWritten = [_outputStream write:(uint8_t const *)[_buffer bytes] maxLength:[_buffer length]]; if (numberOfBytesWritten < 0) { [self close]; return; @@ -1094,7 +1094,7 @@ - (void)handleOutputStreamSpaceAvailable { [_buffer setLength:self.bufferLength]; - NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:[_buffer mutableBytes] maxLength:[_buffer length]]; + NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:(uint8_t *)[_buffer mutableBytes] maxLength:[_buffer length]]; if (numberOfBytesRead < 0) { [self close]; return; From 1ce0a211babf42b84e0ef28b3fa6b4e9f3f1382c Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Thu, 2 May 2013 20:03:17 +0200 Subject: [PATCH 0168/1434] Using self.error instead of self.JSONError in AFJSONRequestOperation. --- AFNetworking/AFJSONRequestOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index ac7423a1a0..6db5f70e8d 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -120,7 +120,7 @@ - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operatio dispatch_async(json_request_operation_processing_queue(), ^{ id JSON = self.responseJSON; - if (self.JSONError) { + if (self.error) { if (failure) { dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ failure(self, self.error); From 9629ff97c3a9418651c3789b40d8f49188fa2949 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 5 May 2013 09:42:39 -0700 Subject: [PATCH 0169/1434] Minor edits to documentation --- AFNetworking/AFHTTPClient.h | 10 +++++----- AFNetworking/AFURLConnectionOperation.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 38c8ca2d58..ddc75dd95c 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -380,7 +380,7 @@ typedef enum { @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and appended as the query string for the request URL. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments: the created request operation and the `NSError` object describing the network or parsing error that occurred. @see -HTTPRequestOperationWithRequest:success:failure: */ @@ -395,7 +395,7 @@ typedef enum { @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and set in the request HTTP body. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments: the created request operation and the `NSError` object describing the network or parsing error that occurred. @see -HTTPRequestOperationWithRequest:success:failure: */ @@ -410,7 +410,7 @@ typedef enum { @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and set in the request HTTP body. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments: the created request operation and the `NSError` object describing the network or parsing error that occurred. @see -HTTPRequestOperationWithRequest:success:failure: */ @@ -425,7 +425,7 @@ typedef enum { @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and appended as the query string for the request URL. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments: the created request operation and the `NSError` object describing the network or parsing error that occurred. @see -HTTPRequestOperationWithRequest:success:failure: */ @@ -440,7 +440,7 @@ typedef enum { @param path The path to be appended to the HTTP client's base URL and used as the request URL. @param parameters The parameters to be encoded and set in the request HTTP body. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments: the created request operation and the `NSError` object describing the network or parsing error that occurred. @see -HTTPRequestOperationWithRequest:success:failure: */ diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 6898e4c9ce..78580295bb 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -284,10 +284,10 @@ NSCoding, NSCopying> /** Sets a block to be executed to determine whether the connection should be able to respond to a protection space's form of authentication, as handled by the `NSURLConnectionDelegate` method `connection:canAuthenticateAgainstProtectionSpace:`. + + If `allowsInvalidSSLCertificate` is set to YES, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. - @param block A block object to be executed to determine whether the connection should be able to respond to a protection space's form of authentication. The block has a `BOOL` return type and takes two arguments: the URL connection object, and the protection space to authenticate against. - - If `allowsInvalidSSLCertificate` is set to YES, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. + @param block A block object to be executed to determine whether the connection should be able to respond to a protection space's form of authentication. The block has a `BOOL` return type and takes two arguments: the URL connection object, and the protection space to authenticate against. */ - (void)setAuthenticationAgainstProtectionSpaceBlock:(BOOL (^)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace))block; From 370c4754c15a58354f7a9abd90b73c5beaf2494d Mon Sep 17 00:00:00 2001 From: joein3d Date: Fri, 19 Apr 2013 23:16:18 -0400 Subject: [PATCH 0170/1434] don't escape tildes as per http://tools.ietf.org/html/rfc3986#section-2.3 --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 1c3aba74ef..a2a10fac37 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -81,7 +81,7 @@ } static NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { - static NSString * const kAFCharactersToBeEscaped = @":/?&=;+!@#$()~',*"; + static NSString * const kAFCharactersToBeEscaped = @":/?&=;+!@#$()',*"; static NSString * const kAFCharactersToLeaveUnescaped = @"[]."; return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, (__bridge CFStringRef)kAFCharactersToLeaveUnescaped, (__bridge CFStringRef)kAFCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)); From 1e27caa9778d174a9ddba7027adc587af1ac752d Mon Sep 17 00:00:00 2001 From: michael_r_may Date: Sun, 5 May 2013 22:18:53 +0100 Subject: [PATCH 0171/1434] Switched the #warning messages to #pragma message messages instead, so you can still compile the framework with -Werror switched on --- AFNetworking/AFHTTPClient.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index ddc75dd95c..2e5d5040b1 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -81,14 +81,14 @@ typedef enum { AFNetworkReachabilityStatusReachableViaWiFi = 2, } AFNetworkReachabilityStatus; #else -#warning SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available. +#pragma message("SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available.") #endif #ifndef __UTTYPE__ #if __IPHONE_OS_VERSION_MIN_REQUIRED -#warning MobileCoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available. +#pragma message("MobileCoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.") #else -#warning CoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available. +#pragma message("CoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.") #endif #endif From ac9563e373be59b253e8df146b3d7159b86900f5 Mon Sep 17 00:00:00 2001 From: Alex Burgel Date: Mon, 6 May 2013 13:18:34 -0400 Subject: [PATCH 0172/1434] Register error if new bodyStream cannot be created --- AFNetworking/AFURLConnectionOperation.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 41034a17b6..563cd56e59 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -703,7 +703,15 @@ - (NSInputStream *)connection:(NSURLConnection __unused *)connection if ([request.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { return [request.HTTPBodyStream copy]; } - + + self.error = [NSError errorWithDomain:AFNetworkingErrorDomain code:NSURLErrorCancelled userInfo:nil]; + + [self.outputStream close]; + + [self finish]; + + self.connection = nil; + return nil; } From a42953f62ee62bdadcf02676e7616cd736aeb975 Mon Sep 17 00:00:00 2001 From: Jeff Hunter Date: Tue, 7 May 2013 13:53:49 -0700 Subject: [PATCH 0173/1434] explicitly synthesize properties to eliminate warnings with -Wobjc-missing-property-synthesis --- AFNetworking/AFHTTPClient.m | 5 +++++ AFNetworking/AFURLConnectionOperation.m | 1 + 2 files changed, 6 insertions(+) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index a2a10fac37..98522ea2fc 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -212,6 +212,10 @@ @implementation AFHTTPClient @synthesize networkReachabilityStatus = _networkReachabilityStatus; @synthesize networkReachabilityStatusBlock = _networkReachabilityStatusBlock; #endif +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +@synthesize defaultSSLPinningMode = _defaultSSLPinningMode; +#endif +@synthesize allowsInvalidSSLCertificate = _allowsInvalidSSLCertificate; + (instancetype)clientWithBaseURL:(NSURL *)url { return [[self alloc] initWithBaseURL:url]; @@ -1186,6 +1190,7 @@ @implementation AFHTTPBodyPart @synthesize headers = _headers; @synthesize body = _body; @synthesize bodyContentLength = _bodyContentLength; +@synthesize inputStream = _inputStream; @synthesize hasInitialBoundary = _hasInitialBoundary; @synthesize hasFinalBoundary = _hasFinalBoundary; diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 41034a17b6..85f2045385 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -138,6 +138,7 @@ @implementation AFURLConnectionOperation @synthesize request = _request; @synthesize response = _response; @synthesize error = _error; +@synthesize allowsInvalidSSLCertificate = _allowsInvalidSSLCertificate; @synthesize responseData = _responseData; @synthesize responseString = _responseString; @synthesize responseStringEncoding = _responseStringEncoding; From fa0c8b8ddccf4115b31febc286e334dbb56fe534 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 8 May 2013 10:17:03 -0700 Subject: [PATCH 0174/1434] Refactoring failure case for connection:needNewBodyStream: --- AFNetworking/AFURLConnectionOperation.m | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index cfe0f9c864..f7688169c9 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -703,17 +703,11 @@ - (NSInputStream *)connection:(NSURLConnection __unused *)connection { if ([request.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { return [request.HTTPBodyStream copy]; + } else { + [self cancelConnection]; + + return nil; } - - self.error = [NSError errorWithDomain:AFNetworkingErrorDomain code:NSURLErrorCancelled userInfo:nil]; - - [self.outputStream close]; - - [self finish]; - - self.connection = nil; - - return nil; } - (NSURLRequest *)connection:(NSURLConnection *)connection From c3db232a5ecc120c06f1f89ceaa8dea79e468b9a Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 8 May 2013 10:23:40 -0700 Subject: [PATCH 0175/1434] [Issue #970] Refactoring network reachability to be more conventional (/thanks @djmadcat) --- AFNetworking/AFHTTPClient.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 98522ea2fc..9a33557296 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -330,12 +330,12 @@ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused targ } static const void * AFNetworkReachabilityRetainCallback(const void *info) { - return (__bridge_retained const void *)([(__bridge AFNetworkReachabilityStatusBlock)info copy]); + return Block_copy(info); } static void AFNetworkReachabilityReleaseCallback(const void *info) { if (info) { - CFRelease(info); + Block_release(info); } } @@ -382,8 +382,9 @@ - (void)startMonitoringNetworkReachability { } - (void)stopMonitoringNetworkReachability { - if (_networkReachability) { - SCNetworkReachabilityUnscheduleFromRunLoop(_networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes); + if (self.networkReachability) { + SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes); + CFRelease(_networkReachability); _networkReachability = NULL; } From 8916a10dc4f0aa00bfbd86a6767805b9d0b28ed2 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 8 May 2013 10:26:49 -0700 Subject: [PATCH 0176/1434] [Issue #969] Reordering network reachability calls to provide correct reachability status on initialization (/thanks @djmadcat) --- AFNetworking/AFHTTPClient.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 9a33557296..f0baeffe00 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -367,7 +367,6 @@ - (void)startMonitoringNetworkReachability { SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); - SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes); /* Network reachability monitoring does not establish a baseline for IP addresses as it does for hostnames, so if the base URL host is an IP address, the initial reachability callback is manually triggered. */ @@ -379,6 +378,8 @@ - (void)startMonitoringNetworkReachability { callback(status); }); } + + SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes); } - (void)stopMonitoringNetworkReachability { From 8fd6eefb2a4b64ac721e42fe0092617c97a6a80f Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 8 May 2013 10:27:25 -0700 Subject: [PATCH 0177/1434] Replacing (CFStringRef)NSRunLoopCommonModes with kCFRunLoopCommonModes --- AFNetworking/AFHTTPClient.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index f0baeffe00..66232f8af1 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -379,12 +379,12 @@ - (void)startMonitoringNetworkReachability { }); } - SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes); + SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); } - (void)stopMonitoringNetworkReachability { if (self.networkReachability) { - SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes); + SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); CFRelease(_networkReachability); _networkReachability = NULL; From 58c890f17ed6cadcd9cc47574e08587f0a3801cf Mon Sep 17 00:00:00 2001 From: Oliver Letterer Date: Wed, 8 May 2013 20:22:07 +0200 Subject: [PATCH 0178/1434] Adds missing [self.response respondsToSelector:@selector(allHeaderFields)] check. --- AFNetworking/AFHTTPRequestOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 80b61f82e3..4d9dd556cb 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -186,7 +186,7 @@ - (void)pause { } NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy]; - if ([[self.response allHeaderFields] valueForKey:@"ETag"]) { + if ([self.response respondsToSelector:@selector(allHeaderFields)] && [[self.response allHeaderFields] valueForKey:@"ETag"]) { [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"]; } [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"]; From 3e5426d54ba7b01e9a4d6d104f4562fc256ca357 Mon Sep 17 00:00:00 2001 From: Josh Vera Date: Fri, 10 May 2013 11:18:57 -0700 Subject: [PATCH 0179/1434] [Issue #963] Perform default handling for NSURLAuthenticationMethodDefault authentication challenges Signed-off-by: Mattt Thompson --- AFNetworking/AFURLConnectionOperation.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index f7688169c9..04e9e5225c 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -630,6 +630,8 @@ - (void)connection:(NSURLConnection *)connection break; } } + } else if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodDefault]) { + [[challenge sender] performDefaultHandlingForAuthenticationChallenge:challenge]; } } #endif From 6f6c888055f197bdbba9829eaadca0f1a0915478 Mon Sep 17 00:00:00 2001 From: xjdrew Date: Fri, 10 May 2013 11:23:25 -0700 Subject: [PATCH 0180/1434] [Issue #942] [Issue #943] Don't attempt to use URL-encoded credentials in connection:didReceiveAuthenticationChallenge:, since any included credentials would have to be invalid to have an authentication challenge be issued Signed-off-by: Mattt Thompson --- AFNetworking/AFURLConnectionOperation.m | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 04e9e5225c..ca978323e1 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -668,25 +668,8 @@ - (void)connection:(NSURLConnection *)connection self.authenticationChallenge(connection, challenge); } else { if ([challenge previousFailureCount] == 0) { - NSURLCredential *credential = nil; - - NSString *user = [[self.request URL] user]; - NSString *password = [[self.request URL] password]; - - if (user && password) { - credential = [NSURLCredential credentialWithUser:user password:password persistence:NSURLCredentialPersistenceNone]; - } else if (user) { - credential = [[[NSURLCredentialStorage sharedCredentialStorage] credentialsForProtectionSpace:[challenge protectionSpace]] objectForKey:user]; - } else { - credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]]; - } - - if (!credential) { - credential = self.credential; - } - - if (credential) { - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + if (self.credential) { + [[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge]; } else { [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; } From 1a25414ef5217c8416d3fad54f03cc21a14e07f5 Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Fri, 10 May 2013 15:53:33 -0400 Subject: [PATCH 0181/1434] Implement initial unit testing and continuous integration system for AFNetworking. refs AFNetworking/AFNetworking#941 --- .gitignore | 2 + .travis.yml | 7 + AFNetworking-Prefix.pch | 16 + AFNetworking.xcodeproj/project.pbxproj | 843 ++++++++++++++++++ .../AFNetworkingFrameworkTests.xcscheme | 69 ++ .../xcschemes/AFNetworkingTests.xcscheme | 69 ++ .../contents.xcworkspacedata | 72 +- AFNetworkingTests/AFHTTPClientTest.m | 24 + .../AFHTTPRequestOperationTest.m | 42 + .../AFNetworkingTests-Info.plist | 22 + AFNetworkingTests/AFNetworkingTests.h | 17 + AFNetworkingTests/AFNetworkingTests.m | 14 + Podfile | 18 + Rakefile | 16 + 14 files changed, 1160 insertions(+), 71 deletions(-) create mode 100644 .travis.yml create mode 100644 AFNetworking-Prefix.pch create mode 100644 AFNetworking.xcodeproj/project.pbxproj create mode 100644 AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingFrameworkTests.xcscheme create mode 100644 AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingTests.xcscheme create mode 100644 AFNetworkingTests/AFHTTPClientTest.m create mode 100644 AFNetworkingTests/AFHTTPRequestOperationTest.m create mode 100644 AFNetworkingTests/AFNetworkingTests-Info.plist create mode 100644 AFNetworkingTests/AFNetworkingTests.h create mode 100644 AFNetworkingTests/AFNetworkingTests.m create mode 100644 Podfile create mode 100644 Rakefile diff --git a/.gitignore b/.gitignore index 89c499e451..aab128c560 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ profile *.moved-aside DerivedData .idea/ +Pods +Podfile.lock diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..bc4be22f96 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: objective-c +before_install: + - brew update + - brew install xctool --HEAD + - gem install cocoapods + - pod install +script: "rake test:all" diff --git a/AFNetworking-Prefix.pch b/AFNetworking-Prefix.pch new file mode 100644 index 0000000000..59f8ee790d --- /dev/null +++ b/AFNetworking-Prefix.pch @@ -0,0 +1,16 @@ +// +// Prefix header for all source files of the 'AFNetworking' target in the 'AFNetworking' project +// + +#ifdef __OBJC__ + #import + + #import + #if __IPHONE_OS_VERSION_MIN_REQUIRED + #import + #import + #else + #import + #import + #endif +#endif diff --git a/AFNetworking.xcodeproj/project.pbxproj b/AFNetworking.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..db2f9bba4b --- /dev/null +++ b/AFNetworking.xcodeproj/project.pbxproj @@ -0,0 +1,843 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0BAD1A5426FC47BF8790D245 /* libPods-ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 55E73C267F33406A9F92476C /* libPods-ios.a */; }; + 2544EC36173BE382004117E8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC35173BE382004117E8 /* Foundation.framework */; }; + 2544EC45173BE382004117E8 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC44173BE382004117E8 /* SenTestingKit.framework */; }; + 2544EC47173BE382004117E8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC46173BE382004117E8 /* UIKit.framework */; }; + 2544EC48173BE382004117E8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC35173BE382004117E8 /* Foundation.framework */; }; + 2544EC4B173BE382004117E8 /* libAFNetworking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC32173BE382004117E8 /* libAFNetworking.a */; }; + 2544EC70173BE4DD004117E8 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC5E173BE4DD004117E8 /* AFHTTPClient.m */; }; + 2544EC71173BE4DD004117E8 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC60173BE4DD004117E8 /* AFHTTPRequestOperation.m */; }; + 2544EC72173BE4DD004117E8 /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC62173BE4DD004117E8 /* AFImageRequestOperation.m */; }; + 2544EC73173BE4DD004117E8 /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC64173BE4DD004117E8 /* AFJSONRequestOperation.m */; }; + 2544EC74173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC66173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m */; }; + 2544EC75173BE4DD004117E8 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC69173BE4DD004117E8 /* AFPropertyListRequestOperation.m */; }; + 2544EC76173BE4DD004117E8 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6B173BE4DD004117E8 /* AFURLConnectionOperation.m */; }; + 2544EC77173BE4DD004117E8 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6D173BE4DD004117E8 /* AFXMLRequestOperation.m */; }; + 2544EC78173BE4DD004117E8 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6F173BE4DD004117E8 /* UIImageView+AFNetworking.m */; }; + 2544EC81173BFAA8004117E8 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC80173BFAA8004117E8 /* Cocoa.framework */; }; + 2544EC96173BFAA8004117E8 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC44173BE382004117E8 /* SenTestingKit.framework */; }; + 2544EC97173BFAA8004117E8 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC80173BFAA8004117E8 /* Cocoa.framework */; }; + 2544EC9A173BFAA8004117E8 /* AFNetworkingFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC7F173BFAA8004117E8 /* AFNetworkingFramework.framework */; }; + 25C4EC0E173D74170083E116 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC5E173BE4DD004117E8 /* AFHTTPClient.m */; }; + 25C4EC10173D74170083E116 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC60173BE4DD004117E8 /* AFHTTPRequestOperation.m */; }; + 25C4EC12173D74170083E116 /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC62173BE4DD004117E8 /* AFImageRequestOperation.m */; }; + 25C4EC14173D74170083E116 /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC64173BE4DD004117E8 /* AFJSONRequestOperation.m */; }; + 25C4EC16173D74170083E116 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC66173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m */; }; + 25C4EC19173D74170083E116 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC69173BE4DD004117E8 /* AFPropertyListRequestOperation.m */; }; + 25C4EC1B173D74170083E116 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6B173BE4DD004117E8 /* AFURLConnectionOperation.m */; }; + 25C4EC1D173D74170083E116 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6D173BE4DD004117E8 /* AFXMLRequestOperation.m */; }; + 25C4EC1F173D74170083E116 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6F173BE4DD004117E8 /* UIImageView+AFNetworking.m */; }; + 25C4EC20173D7A2D0083E116 /* AFHTTPClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC5D173BE4DD004117E8 /* AFHTTPClient.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 25C4EC21173D7A3C0083E116 /* AFHTTPRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC5F173BE4DD004117E8 /* AFHTTPRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 25C4EC22173D7A3C0083E116 /* AFImageRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC61173BE4DD004117E8 /* AFImageRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 25C4EC23173D7A3C0083E116 /* AFJSONRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC63173BE4DD004117E8 /* AFJSONRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 25C4EC24173D7A3C0083E116 /* AFNetworkActivityIndicatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC65173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 25C4EC25173D7A3C0083E116 /* AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC67173BE4DD004117E8 /* AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 25C4EC26173D7A3C0083E116 /* AFPropertyListRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC68173BE4DD004117E8 /* AFPropertyListRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 25C4EC27173D7A3C0083E116 /* AFURLConnectionOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC6A173BE4DD004117E8 /* AFURLConnectionOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 25C4EC28173D7A3C0083E116 /* AFXMLRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC6C173BE4DD004117E8 /* AFXMLRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 25C4EC29173D7A3C0083E116 /* UIImageView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC6E173BE4DD004117E8 /* UIImageView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 25C4EC2B173D7DB30083E116 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC2A173D7DB30083E116 /* SystemConfiguration.framework */; }; + 25C4EC2D173D7DBA0083E116 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC2C173D7DBA0083E116 /* CoreServices.framework */; }; + 25C4EC2F173D7DC40083E116 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC2E173D7DC40083E116 /* CFNetwork.framework */; }; + 25C4EC31173D7DCA0083E116 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */; }; + 25C4EC33173D7DD20083E116 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */; }; + 25C4EC36173D7F3C0083E116 /* AFHTTPClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC35173D7F3C0083E116 /* AFHTTPClientTest.m */; }; + 25C4EC37173D7F3C0083E116 /* AFHTTPClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC35173D7F3C0083E116 /* AFHTTPClientTest.m */; }; + 25C4EC3B173D82290083E116 /* AFNetworkingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC3A173D82290083E116 /* AFNetworkingTests.m */; }; + 25C4EC3C173D82290083E116 /* AFNetworkingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC3A173D82290083E116 /* AFNetworkingTests.m */; }; + 25C4EC3F173D84C70083E116 /* AFHTTPRequestOperationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC3E173D84C70083E116 /* AFHTTPRequestOperationTest.m */; }; + 25C4EC40173D84C70083E116 /* AFHTTPRequestOperationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC3E173D84C70083E116 /* AFHTTPRequestOperationTest.m */; }; + 25C4EC41173D86AE0083E116 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */; }; + 25C4EC42173D86B60083E116 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */; }; + AC11A74923B64A3096ACADFC /* libPods-osx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A923755B00464187DEDBAF /* libPods-osx.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 2544EC49173BE382004117E8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 2544EC2A173BE382004117E8 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 2544EC31173BE382004117E8; + remoteInfo = AFNetworking; + }; + 2544EC98173BFAA8004117E8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 2544EC2A173BE382004117E8 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 2544EC7E173BFAA8004117E8; + remoteInfo = AFNetworkingFramework; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 2544EC30173BE382004117E8 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/${PRODUCT_NAME}"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 2544EC32173BE382004117E8 /* libAFNetworking.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAFNetworking.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 2544EC35173BE382004117E8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 2544EC43173BE382004117E8 /* AFNetworkingTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AFNetworkingTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; + 2544EC44173BE382004117E8 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; + 2544EC46173BE382004117E8 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + 2544EC5D173BE4DD004117E8 /* AFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPClient.h; sourceTree = ""; }; + 2544EC5E173BE4DD004117E8 /* AFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClient.m; sourceTree = ""; }; + 2544EC5F173BE4DD004117E8 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = ""; }; + 2544EC60173BE4DD004117E8 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = ""; }; + 2544EC61173BE4DD004117E8 /* AFImageRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFImageRequestOperation.h; sourceTree = ""; }; + 2544EC62173BE4DD004117E8 /* AFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFImageRequestOperation.m; sourceTree = ""; }; + 2544EC63173BE4DD004117E8 /* AFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFJSONRequestOperation.h; sourceTree = ""; }; + 2544EC64173BE4DD004117E8 /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFJSONRequestOperation.m; sourceTree = ""; }; + 2544EC65173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkActivityIndicatorManager.h; sourceTree = ""; }; + 2544EC66173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkActivityIndicatorManager.m; sourceTree = ""; }; + 2544EC67173BE4DD004117E8 /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworking.h; sourceTree = ""; }; + 2544EC68173BE4DD004117E8 /* AFPropertyListRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFPropertyListRequestOperation.h; sourceTree = ""; }; + 2544EC69173BE4DD004117E8 /* AFPropertyListRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFPropertyListRequestOperation.m; sourceTree = ""; }; + 2544EC6A173BE4DD004117E8 /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLConnectionOperation.h; sourceTree = ""; }; + 2544EC6B173BE4DD004117E8 /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLConnectionOperation.m; sourceTree = ""; }; + 2544EC6C173BE4DD004117E8 /* AFXMLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFXMLRequestOperation.h; sourceTree = ""; }; + 2544EC6D173BE4DD004117E8 /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFXMLRequestOperation.m; sourceTree = ""; }; + 2544EC6E173BE4DD004117E8 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+AFNetworking.h"; sourceTree = ""; }; + 2544EC6F173BE4DD004117E8 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+AFNetworking.m"; sourceTree = ""; }; + 2544EC7F173BFAA8004117E8 /* AFNetworkingFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AFNetworkingFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 2544EC80173BFAA8004117E8 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; + 2544EC83173BFAA8004117E8 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; + 2544EC84173BFAA8004117E8 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + 2544EC85173BFAA8004117E8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 2544EC95173BFAA8004117E8 /* AFNetworkingFrameworkTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AFNetworkingFrameworkTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; + 25C4EC00173BFBA70083E116 /* AFNetworkingTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "AFNetworkingTests-Info.plist"; sourceTree = ""; }; + 25C4EC2A173D7DB30083E116 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; + 25C4EC2C173D7DBA0083E116 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CoreServices.framework; sourceTree = DEVELOPER_DIR; }; + 25C4EC2E173D7DC40083E116 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; + 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; + 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + 25C4EC35173D7F3C0083E116 /* AFHTTPClientTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClientTest.m; sourceTree = ""; }; + 25C4EC39173D7F9E0083E116 /* AFNetworkingTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AFNetworkingTests.h; sourceTree = ""; }; + 25C4EC3A173D82290083E116 /* AFNetworkingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkingTests.m; sourceTree = ""; }; + 25C4EC3E173D84C70083E116 /* AFHTTPRequestOperationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperationTest.m; sourceTree = ""; }; + 3A9F6CCEA1634087A54CA260 /* Pods-osx.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-osx.xcconfig"; path = "Pods/Pods-osx.xcconfig"; sourceTree = SOURCE_ROOT; }; + 4185EE53DF5646419AE66CA0 /* Pods-ios.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios.xcconfig"; path = "Pods/Pods-ios.xcconfig"; sourceTree = SOURCE_ROOT; }; + 55E73C267F33406A9F92476C /* libPods-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 96A923755B00464187DEDBAF /* libPods-osx.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-osx.a"; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2544EC2F173BE382004117E8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 25C4EC33173D7DD20083E116 /* SystemConfiguration.framework in Frameworks */, + 25C4EC31173D7DCA0083E116 /* MobileCoreServices.framework in Frameworks */, + 25C4EC2F173D7DC40083E116 /* CFNetwork.framework in Frameworks */, + 2544EC36173BE382004117E8 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2544EC3F173BE382004117E8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 25C4EC42173D86B60083E116 /* MobileCoreServices.framework in Frameworks */, + 25C4EC41173D86AE0083E116 /* SystemConfiguration.framework in Frameworks */, + 2544EC45173BE382004117E8 /* SenTestingKit.framework in Frameworks */, + 2544EC47173BE382004117E8 /* UIKit.framework in Frameworks */, + 2544EC48173BE382004117E8 /* Foundation.framework in Frameworks */, + 2544EC4B173BE382004117E8 /* libAFNetworking.a in Frameworks */, + 0BAD1A5426FC47BF8790D245 /* libPods-ios.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2544EC7B173BFAA8004117E8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 25C4EC2D173D7DBA0083E116 /* CoreServices.framework in Frameworks */, + 25C4EC2B173D7DB30083E116 /* SystemConfiguration.framework in Frameworks */, + 2544EC81173BFAA8004117E8 /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2544EC91173BFAA8004117E8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2544EC96173BFAA8004117E8 /* SenTestingKit.framework in Frameworks */, + 2544EC97173BFAA8004117E8 /* Cocoa.framework in Frameworks */, + 2544EC9A173BFAA8004117E8 /* AFNetworkingFramework.framework in Frameworks */, + AC11A74923B64A3096ACADFC /* libPods-osx.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2544EC29173BE382004117E8 = { + isa = PBXGroup; + children = ( + 2544EC37173BE382004117E8 /* AFNetworking */, + 25C4EBFF173BFBA70083E116 /* AFNetworkingTests */, + 2544EC34173BE382004117E8 /* Frameworks */, + 2544EC33173BE382004117E8 /* Products */, + ); + sourceTree = ""; + }; + 2544EC33173BE382004117E8 /* Products */ = { + isa = PBXGroup; + children = ( + 2544EC32173BE382004117E8 /* libAFNetworking.a */, + 2544EC43173BE382004117E8 /* AFNetworkingTests.octest */, + 2544EC7F173BFAA8004117E8 /* AFNetworkingFramework.framework */, + 2544EC95173BFAA8004117E8 /* AFNetworkingFrameworkTests.octest */, + ); + name = Products; + sourceTree = ""; + }; + 2544EC34173BE382004117E8 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */, + 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */, + 25C4EC2E173D7DC40083E116 /* CFNetwork.framework */, + 25C4EC2C173D7DBA0083E116 /* CoreServices.framework */, + 25C4EC2A173D7DB30083E116 /* SystemConfiguration.framework */, + 2544EC35173BE382004117E8 /* Foundation.framework */, + 2544EC44173BE382004117E8 /* SenTestingKit.framework */, + 2544EC46173BE382004117E8 /* UIKit.framework */, + 2544EC80173BFAA8004117E8 /* Cocoa.framework */, + 2544EC82173BFAA8004117E8 /* Other Frameworks */, + 55E73C267F33406A9F92476C /* libPods-ios.a */, + 96A923755B00464187DEDBAF /* libPods-osx.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + 2544EC37173BE382004117E8 /* AFNetworking */ = { + isa = PBXGroup; + children = ( + 2544EC5D173BE4DD004117E8 /* AFHTTPClient.h */, + 2544EC5E173BE4DD004117E8 /* AFHTTPClient.m */, + 2544EC5F173BE4DD004117E8 /* AFHTTPRequestOperation.h */, + 2544EC60173BE4DD004117E8 /* AFHTTPRequestOperation.m */, + 2544EC61173BE4DD004117E8 /* AFImageRequestOperation.h */, + 2544EC62173BE4DD004117E8 /* AFImageRequestOperation.m */, + 2544EC63173BE4DD004117E8 /* AFJSONRequestOperation.h */, + 2544EC64173BE4DD004117E8 /* AFJSONRequestOperation.m */, + 2544EC65173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.h */, + 2544EC66173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m */, + 2544EC67173BE4DD004117E8 /* AFNetworking.h */, + 2544EC68173BE4DD004117E8 /* AFPropertyListRequestOperation.h */, + 2544EC69173BE4DD004117E8 /* AFPropertyListRequestOperation.m */, + 2544EC6A173BE4DD004117E8 /* AFURLConnectionOperation.h */, + 2544EC6B173BE4DD004117E8 /* AFURLConnectionOperation.m */, + 2544EC6C173BE4DD004117E8 /* AFXMLRequestOperation.h */, + 2544EC6D173BE4DD004117E8 /* AFXMLRequestOperation.m */, + 2544EC6E173BE4DD004117E8 /* UIImageView+AFNetworking.h */, + 2544EC6F173BE4DD004117E8 /* UIImageView+AFNetworking.m */, + ); + path = AFNetworking; + sourceTree = ""; + }; + 2544EC82173BFAA8004117E8 /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 2544EC83173BFAA8004117E8 /* AppKit.framework */, + 2544EC84173BFAA8004117E8 /* CoreData.framework */, + 2544EC85173BFAA8004117E8 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 25C4EBFF173BFBA70083E116 /* AFNetworkingTests */ = { + isa = PBXGroup; + children = ( + 25C4EC3E173D84C70083E116 /* AFHTTPRequestOperationTest.m */, + 25C4EC35173D7F3C0083E116 /* AFHTTPClientTest.m */, + 25C4EC39173D7F9E0083E116 /* AFNetworkingTests.h */, + 25C4EC3A173D82290083E116 /* AFNetworkingTests.m */, + 25C4EC38173D7F5A0083E116 /* Support */, + ); + path = AFNetworkingTests; + sourceTree = ""; + }; + 25C4EC38173D7F5A0083E116 /* Support */ = { + isa = PBXGroup; + children = ( + 4185EE53DF5646419AE66CA0 /* Pods-ios.xcconfig */, + 3A9F6CCEA1634087A54CA260 /* Pods-osx.xcconfig */, + 25C4EC00173BFBA70083E116 /* AFNetworkingTests-Info.plist */, + ); + name = Support; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 2544EC7C173BFAA8004117E8 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 25C4EC20173D7A2D0083E116 /* AFHTTPClient.h in Headers */, + 25C4EC21173D7A3C0083E116 /* AFHTTPRequestOperation.h in Headers */, + 25C4EC22173D7A3C0083E116 /* AFImageRequestOperation.h in Headers */, + 25C4EC23173D7A3C0083E116 /* AFJSONRequestOperation.h in Headers */, + 25C4EC24173D7A3C0083E116 /* AFNetworkActivityIndicatorManager.h in Headers */, + 25C4EC25173D7A3C0083E116 /* AFNetworking.h in Headers */, + 25C4EC26173D7A3C0083E116 /* AFPropertyListRequestOperation.h in Headers */, + 25C4EC27173D7A3C0083E116 /* AFURLConnectionOperation.h in Headers */, + 25C4EC28173D7A3C0083E116 /* AFXMLRequestOperation.h in Headers */, + 25C4EC29173D7A3C0083E116 /* UIImageView+AFNetworking.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 2544EC31173BE382004117E8 /* AFNetworking */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2544EC57173BE382004117E8 /* Build configuration list for PBXNativeTarget "AFNetworking" */; + buildPhases = ( + 2544EC2E173BE382004117E8 /* Sources */, + 2544EC2F173BE382004117E8 /* Frameworks */, + 2544EC30173BE382004117E8 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AFNetworking; + productName = AFNetworking; + productReference = 2544EC32173BE382004117E8 /* libAFNetworking.a */; + productType = "com.apple.product-type.library.static"; + }; + 2544EC42173BE382004117E8 /* AFNetworkingTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2544EC5A173BE382004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingTests" */; + buildPhases = ( + A56DF943F839492A82A2E686 /* Check Pods Manifest.lock */, + 2544EC3E173BE382004117E8 /* Sources */, + 2544EC3F173BE382004117E8 /* Frameworks */, + 2544EC40173BE382004117E8 /* Resources */, + 2544EC41173BE382004117E8 /* ShellScript */, + B64BACD31A5E4E469B8FA901 /* Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + 2544EC4A173BE382004117E8 /* PBXTargetDependency */, + ); + name = AFNetworkingTests; + productName = AFNetworkingTests; + productReference = 2544EC43173BE382004117E8 /* AFNetworkingTests.octest */; + productType = "com.apple.product-type.bundle"; + }; + 2544EC7E173BFAA8004117E8 /* AFNetworkingFramework */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2544ECA4173BFAA8004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingFramework" */; + buildPhases = ( + 2544EC7A173BFAA8004117E8 /* Sources */, + 2544EC7B173BFAA8004117E8 /* Frameworks */, + 2544EC7C173BFAA8004117E8 /* Headers */, + 2544EC7D173BFAA8004117E8 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AFNetworkingFramework; + productName = AFNetworkingFramework; + productReference = 2544EC7F173BFAA8004117E8 /* AFNetworkingFramework.framework */; + productType = "com.apple.product-type.framework"; + }; + 2544EC94173BFAA8004117E8 /* AFNetworkingFrameworkTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2544ECA7173BFAA8004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingFrameworkTests" */; + buildPhases = ( + B5A6770A8EDC4CF7A709C8BD /* Check Pods Manifest.lock */, + 2544EC90173BFAA8004117E8 /* Sources */, + 2544EC91173BFAA8004117E8 /* Frameworks */, + 2544EC92173BFAA8004117E8 /* Resources */, + 2544EC93173BFAA8004117E8 /* ShellScript */, + B72AAA1CF47A4D7CAF8BEB66 /* Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + 2544EC99173BFAA8004117E8 /* PBXTargetDependency */, + ); + name = AFNetworkingFrameworkTests; + productName = AFNetworkingFrameworkTests; + productReference = 2544EC95173BFAA8004117E8 /* AFNetworkingFrameworkTests.octest */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2544EC2A173BE382004117E8 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0460; + ORGANIZATIONNAME = AFNetworking; + }; + buildConfigurationList = 2544EC2D173BE382004117E8 /* Build configuration list for PBXProject "AFNetworking" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 2544EC29173BE382004117E8; + productRefGroup = 2544EC33173BE382004117E8 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 2544EC31173BE382004117E8 /* AFNetworking */, + 2544EC42173BE382004117E8 /* AFNetworkingTests */, + 2544EC7E173BFAA8004117E8 /* AFNetworkingFramework */, + 2544EC94173BFAA8004117E8 /* AFNetworkingFrameworkTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 2544EC40173BE382004117E8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2544EC7D173BFAA8004117E8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2544EC92173BFAA8004117E8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 2544EC41173BE382004117E8 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; + }; + 2544EC93173BFAA8004117E8 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; + }; + A56DF943F839492A82A2E686 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + }; + B5A6770A8EDC4CF7A709C8BD /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + }; + B64BACD31A5E4E469B8FA901 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Pods-ios-resources.sh\"\n"; + }; + B72AAA1CF47A4D7CAF8BEB66 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Pods-osx-resources.sh\"\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2544EC2E173BE382004117E8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2544EC70173BE4DD004117E8 /* AFHTTPClient.m in Sources */, + 2544EC71173BE4DD004117E8 /* AFHTTPRequestOperation.m in Sources */, + 2544EC72173BE4DD004117E8 /* AFImageRequestOperation.m in Sources */, + 2544EC73173BE4DD004117E8 /* AFJSONRequestOperation.m in Sources */, + 2544EC74173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m in Sources */, + 2544EC75173BE4DD004117E8 /* AFPropertyListRequestOperation.m in Sources */, + 2544EC76173BE4DD004117E8 /* AFURLConnectionOperation.m in Sources */, + 2544EC77173BE4DD004117E8 /* AFXMLRequestOperation.m in Sources */, + 2544EC78173BE4DD004117E8 /* UIImageView+AFNetworking.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2544EC3E173BE382004117E8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 25C4EC36173D7F3C0083E116 /* AFHTTPClientTest.m in Sources */, + 25C4EC3B173D82290083E116 /* AFNetworkingTests.m in Sources */, + 25C4EC3F173D84C70083E116 /* AFHTTPRequestOperationTest.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2544EC7A173BFAA8004117E8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 25C4EC0E173D74170083E116 /* AFHTTPClient.m in Sources */, + 25C4EC10173D74170083E116 /* AFHTTPRequestOperation.m in Sources */, + 25C4EC12173D74170083E116 /* AFImageRequestOperation.m in Sources */, + 25C4EC14173D74170083E116 /* AFJSONRequestOperation.m in Sources */, + 25C4EC16173D74170083E116 /* AFNetworkActivityIndicatorManager.m in Sources */, + 25C4EC19173D74170083E116 /* AFPropertyListRequestOperation.m in Sources */, + 25C4EC1B173D74170083E116 /* AFURLConnectionOperation.m in Sources */, + 25C4EC1D173D74170083E116 /* AFXMLRequestOperation.m in Sources */, + 25C4EC1F173D74170083E116 /* UIImageView+AFNetworking.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2544EC90173BFAA8004117E8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 25C4EC37173D7F3C0083E116 /* AFHTTPClientTest.m in Sources */, + 25C4EC3C173D82290083E116 /* AFNetworkingTests.m in Sources */, + 25C4EC40173D84C70083E116 /* AFHTTPRequestOperationTest.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 2544EC4A173BE382004117E8 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 2544EC31173BE382004117E8 /* AFNetworking */; + targetProxy = 2544EC49173BE382004117E8 /* PBXContainerItemProxy */; + }; + 2544EC99173BFAA8004117E8 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 2544EC7E173BFAA8004117E8 /* AFNetworkingFramework */; + targetProxy = 2544EC98173BFAA8004117E8 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 2544EC55173BE382004117E8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 2544EC56173BE382004117E8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 2544EC58173BE382004117E8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/AFNetworking.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 2544EC59173BE382004117E8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/AFNetworking.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; + 2544EC5B173BE382004117E8 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4185EE53DF5646419AE66CA0 /* Pods-ios.xcconfig */; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "\"$(SDKROOT)/Developer/Library/Frameworks\"", + "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + INFOPLIST_FILE = "AFNetworkingTests/AFNetworkingTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = octest; + }; + name = Debug; + }; + 2544EC5C173BE382004117E8 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4185EE53DF5646419AE66CA0 /* Pods-ios.xcconfig */; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "\"$(SDKROOT)/Developer/Library/Frameworks\"", + "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + INFOPLIST_FILE = "AFNetworkingTests/AFNetworkingTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = octest; + }; + name = Release; + }; + 2544ECA5173BFAA8004117E8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COMBINE_HIDPI_IMAGES = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Library/Frameworks\"", + ); + FRAMEWORK_VERSION = A; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + WRAPPER_EXTENSION = framework; + }; + name = Debug; + }; + 2544ECA6173BFAA8004117E8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Library/Frameworks\"", + ); + FRAMEWORK_VERSION = A; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + WRAPPER_EXTENSION = framework; + }; + name = Release; + }; + 2544ECA8173BFAA8004117E8 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 3A9F6CCEA1634087A54CA260 /* Pods-osx.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COMBINE_HIDPI_IMAGES = YES; + FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + INFOPLIST_FILE = "AFNetworkingTests/AFNetworkingTests-Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.8; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + WRAPPER_EXTENSION = octest; + }; + name = Debug; + }; + 2544ECA9173BFAA8004117E8 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 3A9F6CCEA1634087A54CA260 /* Pods-osx.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + INFOPLIST_FILE = "AFNetworkingTests/AFNetworkingTests-Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.8; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + WRAPPER_EXTENSION = octest; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2544EC2D173BE382004117E8 /* Build configuration list for PBXProject "AFNetworking" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2544EC55173BE382004117E8 /* Debug */, + 2544EC56173BE382004117E8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2544EC57173BE382004117E8 /* Build configuration list for PBXNativeTarget "AFNetworking" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2544EC58173BE382004117E8 /* Debug */, + 2544EC59173BE382004117E8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2544EC5A173BE382004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2544EC5B173BE382004117E8 /* Debug */, + 2544EC5C173BE382004117E8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2544ECA4173BFAA8004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingFramework" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2544ECA5173BFAA8004117E8 /* Debug */, + 2544ECA6173BFAA8004117E8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2544ECA7173BFAA8004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingFrameworkTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2544ECA8173BFAA8004117E8 /* Debug */, + 2544ECA9173BFAA8004117E8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2544EC2A173BE382004117E8 /* Project object */; +} diff --git a/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingFrameworkTests.xcscheme b/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingFrameworkTests.xcscheme new file mode 100644 index 0000000000..050ad6dfb4 --- /dev/null +++ b/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingFrameworkTests.xcscheme @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingTests.xcscheme b/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingTests.xcscheme new file mode 100644 index 0000000000..5126d14e99 --- /dev/null +++ b/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingTests.xcscheme @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AFNetworking.xcworkspace/contents.xcworkspacedata b/AFNetworking.xcworkspace/contents.xcworkspacedata index 66991fbcad..5608804766 100644 --- a/AFNetworking.xcworkspace/contents.xcworkspacedata +++ b/AFNetworking.xcworkspace/contents.xcworkspacedata @@ -1,71 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/AFNetworkingTests/AFHTTPClientTest.m b/AFNetworkingTests/AFHTTPClientTest.m new file mode 100644 index 0000000000..9e041664fb --- /dev/null +++ b/AFNetworkingTests/AFHTTPClientTest.m @@ -0,0 +1,24 @@ +// +// AFHTTPClientTest.m +// AFNetworking +// +// Created by Blake Watters on 5/10/13. +// Copyright (c) 2013 AFNetworking. All rights reserved. +// + +#import "AFNetworkingTests.h" + +@interface AFHTTPClientTest : SenTestCase +@end + +@implementation AFHTTPClientTest + +- (void)testThatTheDefaultStringEncodingIsUTF8 +{ + AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; + expect(client.stringEncoding).to.equal(NSUTF8StringEncoding); +} + +// default value for header + +@end diff --git a/AFNetworkingTests/AFHTTPRequestOperationTest.m b/AFNetworkingTests/AFHTTPRequestOperationTest.m new file mode 100644 index 0000000000..03771bedb3 --- /dev/null +++ b/AFNetworkingTests/AFHTTPRequestOperationTest.m @@ -0,0 +1,42 @@ +// +// AFHTTPRequestOperationTest.m +// AFNetworking +// +// Created by Blake Watters on 5/10/13. +// Copyright (c) 2013 AFNetworking. All rights reserved. +// + +#import "AFNetworkingTests.h" + +@interface AFHTTPRequestOperationTest : SenTestCase +@end + +@implementation AFHTTPRequestOperationTest + +- (void)testThatOperationInvokesSuccessCompletionBlockWithResponseObjectOnSuccess +{ + __block id blockResponseObject = nil; + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/get" relativeToURL:AFNetworkingTestsBaseURL()]]; + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + blockResponseObject = responseObject; + } failure:nil]; + [operation start]; + expect([operation isFinished]).will.beTruthy(); + expect(blockResponseObject).willNot.beNil(); +} + +- (void)testThatOperationInvokesFailureCompletionBlockWithErrorOnFailure +{ + __block NSError *blockError = nil; + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/404" relativeToURL:AFNetworkingTestsBaseURL()]]; + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + [operation setCompletionBlockWithSuccess:nil failure:^(AFHTTPRequestOperation *operation, NSError *error) { + blockError = error; + }]; + [operation start]; + expect([operation isFinished]).will.beTruthy(); + expect(blockError).willNot.beNil(); +} + +@end diff --git a/AFNetworkingTests/AFNetworkingTests-Info.plist b/AFNetworkingTests/AFNetworkingTests-Info.plist new file mode 100644 index 0000000000..28925ffd83 --- /dev/null +++ b/AFNetworkingTests/AFNetworkingTests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + org.afnetworking.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/AFNetworkingTests/AFNetworkingTests.h b/AFNetworkingTests/AFNetworkingTests.h new file mode 100644 index 0000000000..05c11d335b --- /dev/null +++ b/AFNetworkingTests/AFNetworkingTests.h @@ -0,0 +1,17 @@ +// +// AFNetworkingTests.h +// AFNetworking +// +// Created by Blake Watters on 5/10/13. +// Copyright (c) 2013 AFNetworking. All rights reserved. +// + +#import +#import "AFNetworking.h" + +#define EXP_SHORTHAND YES +#import "Expecta.h" +#import "OCMock.h" + +extern NSString *AFNetworkingTestsBaseURLString; +NSURL *AFNetworkingTestsBaseURL(void); diff --git a/AFNetworkingTests/AFNetworkingTests.m b/AFNetworkingTests/AFNetworkingTests.m new file mode 100644 index 0000000000..df81adbba4 --- /dev/null +++ b/AFNetworkingTests/AFNetworkingTests.m @@ -0,0 +1,14 @@ +// +// AFNetworkingTests.m +// AFNetworking +// +// Created by Blake Watters on 5/10/13. +// Copyright (c) 2013 AFNetworking. All rights reserved. +// + +NSString *AFNetworkingTestsBaseURLString = @"http://httpbin.org/"; + +NSURL *AFNetworkingTestsBaseURL(void) +{ + return [NSURL URLWithString:AFNetworkingTestsBaseURLString]; +} diff --git a/Podfile b/Podfile new file mode 100644 index 0000000000..2ab86c14e3 --- /dev/null +++ b/Podfile @@ -0,0 +1,18 @@ +inhibit_all_warnings! + +def import_pods + pod 'OCMock', '2.1.1' + pod 'Expecta', '0.2.1' +end + +target :ios do + platform :ios, '5.0' + link_with 'AFNetworkingTests' + import_pods +end + +target :osx do + platform :osx, '10.7' + link_with 'AFNetworkingFrameworkTests' + import_pods +end diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000000..5b37a51bb9 --- /dev/null +++ b/Rakefile @@ -0,0 +1,16 @@ +namespace :test do + desc "Run the AFNetworking Tests for iOS" + task :ios do + system('xctool -workspace AFNetworking.xcworkspace -scheme AFNetworkingTests test -test-sdk iphonesimulator') + end + + desc "Run the AFNetworking Tests for Mac OS X" + task :osx do + system('xctool -workspace AFNetworking.xcworkspace -scheme AFNetworkingFrameworkTests test -test-sdk macosx -sdk macosx') + end + + desc "Run the AFNetworking Tests for iOS & Mac OS X" + task :all => ['test:ios', 'test:osx'] +end + +task :default => 'test:all' From 85faf3477fa603a08154a39ca489e5575388a99a Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Fri, 10 May 2013 16:07:40 -0400 Subject: [PATCH 0182/1434] Add Travis CI build status logo to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e60615f5ff..722490688d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ AFNetworking

+[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.png?branch=master)](https://travis-ci.org/AFNetworking/AFNetworking) + AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of [NSURLConnection](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html), [NSOperation](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperation_class/Reference/Reference.html), and other familiar Foundation technologies. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. For example, here's how easy it is to get JSON from a URL: ``` objective-c From 91db618d8e04081e27e27d2e394bf3cea5c37705 Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Fri, 10 May 2013 17:10:56 -0400 Subject: [PATCH 0183/1434] Remove unnecessary CocoaPods setup during Travis build execution --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bc4be22f96..88802781c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,4 @@ language: objective-c before_install: - brew update - brew install xctool --HEAD - - gem install cocoapods - - pod install script: "rake test:all" From 7d89a1897d21042419984479b1c92ad0098d6d99 Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Fri, 10 May 2013 17:32:00 -0400 Subject: [PATCH 0184/1434] Cleanup Podfile and remove overridden OTHER_LDFLAGS on AFNetworking static library target --- AFNetworking.xcodeproj/project.pbxproj | 40 ++++++++++++++++++++++++-- Podfile | 8 ++---- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/AFNetworking.xcodeproj/project.pbxproj b/AFNetworking.xcodeproj/project.pbxproj index db2f9bba4b..508d38a580 100644 --- a/AFNetworking.xcodeproj/project.pbxproj +++ b/AFNetworking.xcodeproj/project.pbxproj @@ -58,6 +58,7 @@ 25C4EC40173D84C70083E116 /* AFHTTPRequestOperationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC3E173D84C70083E116 /* AFHTTPRequestOperationTest.m */; }; 25C4EC41173D86AE0083E116 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */; }; 25C4EC42173D86B60083E116 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */; }; + 8C3F274EB4534B2EA29AB3D6 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B6D24F8E1B74E10A269E8B3 /* libPods.a */; }; AC11A74923B64A3096ACADFC /* libPods-osx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A923755B00464187DEDBAF /* libPods-osx.a */; }; /* End PBXBuildFile section */ @@ -91,6 +92,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 12BB563617304561A5E20CE5 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = SOURCE_ROOT; }; 2544EC32173BE382004117E8 /* libAFNetworking.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAFNetworking.a; sourceTree = BUILT_PRODUCTS_DIR; }; 2544EC35173BE382004117E8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 2544EC43173BE382004117E8 /* AFNetworkingTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AFNetworkingTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -131,6 +133,7 @@ 25C4EC39173D7F9E0083E116 /* AFNetworkingTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AFNetworkingTests.h; sourceTree = ""; }; 25C4EC3A173D82290083E116 /* AFNetworkingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkingTests.m; sourceTree = ""; }; 25C4EC3E173D84C70083E116 /* AFHTTPRequestOperationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperationTest.m; sourceTree = ""; }; + 2B6D24F8E1B74E10A269E8B3 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 3A9F6CCEA1634087A54CA260 /* Pods-osx.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-osx.xcconfig"; path = "Pods/Pods-osx.xcconfig"; sourceTree = SOURCE_ROOT; }; 4185EE53DF5646419AE66CA0 /* Pods-ios.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios.xcconfig"; path = "Pods/Pods-ios.xcconfig"; sourceTree = SOURCE_ROOT; }; 55E73C267F33406A9F92476C /* libPods-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -146,6 +149,7 @@ 25C4EC31173D7DCA0083E116 /* MobileCoreServices.framework in Frameworks */, 25C4EC2F173D7DC40083E116 /* CFNetwork.framework in Frameworks */, 2544EC36173BE382004117E8 /* Foundation.framework in Frameworks */, + 8C3F274EB4534B2EA29AB3D6 /* libPods.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -194,6 +198,7 @@ 25C4EBFF173BFBA70083E116 /* AFNetworkingTests */, 2544EC34173BE382004117E8 /* Frameworks */, 2544EC33173BE382004117E8 /* Products */, + 12BB563617304561A5E20CE5 /* Pods.xcconfig */, ); sourceTree = ""; }; @@ -223,6 +228,7 @@ 2544EC82173BFAA8004117E8 /* Other Frameworks */, 55E73C267F33406A9F92476C /* libPods-ios.a */, 96A923755B00464187DEDBAF /* libPods-osx.a */, + 2B6D24F8E1B74E10A269E8B3 /* libPods.a */, ); name = Frameworks; sourceTree = ""; @@ -312,9 +318,11 @@ isa = PBXNativeTarget; buildConfigurationList = 2544EC57173BE382004117E8 /* Build configuration list for PBXNativeTarget "AFNetworking" */; buildPhases = ( + 1B236131E70E4B509829D632 /* Check Pods Manifest.lock */, 2544EC2E173BE382004117E8 /* Sources */, 2544EC2F173BE382004117E8 /* Frameworks */, 2544EC30173BE382004117E8 /* CopyFiles */, + 1B83324CD2F543A0B1C9BCF3 /* Copy Pods Resources */, ); buildRules = ( ); @@ -439,6 +447,34 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 1B236131E70E4B509829D632 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + }; + 1B83324CD2F543A0B1C9BCF3 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Pods-resources.sh\"\n"; + }; 2544EC41173BE382004117E8 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -647,12 +683,12 @@ }; 2544EC58173BE382004117E8 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 12BB563617304561A5E20CE5 /* Pods.xcconfig */; buildSettings = { DSTROOT = /tmp/AFNetworking.dst; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; IPHONEOS_DEPLOYMENT_TARGET = 5.0; - OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; @@ -660,12 +696,12 @@ }; 2544EC59173BE382004117E8 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 12BB563617304561A5E20CE5 /* Pods.xcconfig */; buildSettings = { DSTROOT = /tmp/AFNetworking.dst; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; IPHONEOS_DEPLOYMENT_TARGET = 5.0; - OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; diff --git a/Podfile b/Podfile index 2ab86c14e3..6c056a65ca 100644 --- a/Podfile +++ b/Podfile @@ -1,18 +1,14 @@ inhibit_all_warnings! -def import_pods - pod 'OCMock', '2.1.1' - pod 'Expecta', '0.2.1' -end +pod 'OCMock', '2.1.1' +pod 'Expecta', '0.2.1' target :ios do platform :ios, '5.0' link_with 'AFNetworkingTests' - import_pods end target :osx do platform :osx, '10.7' link_with 'AFNetworkingFrameworkTests' - import_pods end From 5bfde2ab4d0509d25170d6abd77f6b573044d94a Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Fri, 10 May 2013 18:11:40 -0400 Subject: [PATCH 0185/1434] Restore previous break-out of Pods configuration as the global import links it into the wrong targets --- AFNetworking.xcodeproj/project.pbxproj | 34 -------------------------- Podfile | 8 ++++-- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/AFNetworking.xcodeproj/project.pbxproj b/AFNetworking.xcodeproj/project.pbxproj index 508d38a580..b78baa57b9 100644 --- a/AFNetworking.xcodeproj/project.pbxproj +++ b/AFNetworking.xcodeproj/project.pbxproj @@ -92,7 +92,6 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 12BB563617304561A5E20CE5 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = SOURCE_ROOT; }; 2544EC32173BE382004117E8 /* libAFNetworking.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAFNetworking.a; sourceTree = BUILT_PRODUCTS_DIR; }; 2544EC35173BE382004117E8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 2544EC43173BE382004117E8 /* AFNetworkingTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AFNetworkingTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -198,7 +197,6 @@ 25C4EBFF173BFBA70083E116 /* AFNetworkingTests */, 2544EC34173BE382004117E8 /* Frameworks */, 2544EC33173BE382004117E8 /* Products */, - 12BB563617304561A5E20CE5 /* Pods.xcconfig */, ); sourceTree = ""; }; @@ -318,11 +316,9 @@ isa = PBXNativeTarget; buildConfigurationList = 2544EC57173BE382004117E8 /* Build configuration list for PBXNativeTarget "AFNetworking" */; buildPhases = ( - 1B236131E70E4B509829D632 /* Check Pods Manifest.lock */, 2544EC2E173BE382004117E8 /* Sources */, 2544EC2F173BE382004117E8 /* Frameworks */, 2544EC30173BE382004117E8 /* CopyFiles */, - 1B83324CD2F543A0B1C9BCF3 /* Copy Pods Resources */, ); buildRules = ( ); @@ -447,34 +443,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 1B236131E70E4B509829D632 /* Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Check Pods Manifest.lock"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; - }; - 1B83324CD2F543A0B1C9BCF3 /* Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Pods-resources.sh\"\n"; - }; 2544EC41173BE382004117E8 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -683,7 +651,6 @@ }; 2544EC58173BE382004117E8 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 12BB563617304561A5E20CE5 /* Pods.xcconfig */; buildSettings = { DSTROOT = /tmp/AFNetworking.dst; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -696,7 +663,6 @@ }; 2544EC59173BE382004117E8 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 12BB563617304561A5E20CE5 /* Pods.xcconfig */; buildSettings = { DSTROOT = /tmp/AFNetworking.dst; GCC_PRECOMPILE_PREFIX_HEADER = YES; diff --git a/Podfile b/Podfile index 6c056a65ca..2ab86c14e3 100644 --- a/Podfile +++ b/Podfile @@ -1,14 +1,18 @@ inhibit_all_warnings! -pod 'OCMock', '2.1.1' -pod 'Expecta', '0.2.1' +def import_pods + pod 'OCMock', '2.1.1' + pod 'Expecta', '0.2.1' +end target :ios do platform :ios, '5.0' link_with 'AFNetworkingTests' + import_pods end target :osx do platform :osx, '10.7' link_with 'AFNetworkingFrameworkTests' + import_pods end From bc3b94f79d2e32b77b0ae553939f4e486c0fdb4f Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Sat, 11 May 2013 12:53:24 -0400 Subject: [PATCH 0186/1434] Add Podfile.lock to the project --- .gitignore | 1 - Podfile.lock | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 Podfile.lock diff --git a/.gitignore b/.gitignore index aab128c560..94ed2b58f0 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,3 @@ profile DerivedData .idea/ Pods -Podfile.lock diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 0000000000..e07e86af4e --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,13 @@ +PODS: + - Expecta (0.2.1) + - OCMock (2.1.1) + +DEPENDENCIES: + - Expecta (= 0.2.1) + - OCMock (= 2.1.1) + +SPEC CHECKSUMS: + Expecta: d46fb1bd78c90a83da0158b9b1e108de106e369f + OCMock: 79212e5e328378af5cfd6edb5feacfd6c49cd8a3 + +COCOAPODS: 0.19.1 From 4f04b35378438ffc6d9b4ca3870e1a6ea3a4e0bd Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Sat, 11 May 2013 13:18:43 -0400 Subject: [PATCH 0187/1434] Reorganize testing setup * Eliminate static library and framework targets * Migrate all testing infrastructure and code to Tests/ * Nest CocoaPods setup for testing under Tests/ * Remove explicit dependencies from shared schemes --- .gitignore | 2 +- AFNetworking.xcodeproj/project.pbxproj | 845 ------------------ .../contents.xcworkspacedata | 17 +- .../AFHTTPClientTest.m | 0 .../AFHTTPRequestOperationTest.m | 0 .../project.pbxproj | 517 +++++++++++ .../xcschemes/OS X Tests.xcscheme | 6 +- .../xcshareddata/xcschemes/iOS Tests.xcscheme | 10 +- .../AFNetworking-Prefix.pch | 0 .../AFNetworkingTests-Info.plist | 0 .../AFNetworkingTests.h | 0 .../AFNetworkingTests.m | 0 Podfile => Tests/Podfile | 6 +- Podfile.lock => Tests/Podfile.lock | 0 14 files changed, 546 insertions(+), 857 deletions(-) delete mode 100644 AFNetworking.xcodeproj/project.pbxproj rename {AFNetworkingTests => Tests}/AFHTTPClientTest.m (100%) rename {AFNetworkingTests => Tests}/AFHTTPRequestOperationTest.m (100%) create mode 100644 Tests/AFNetworking Tests.xcodeproj/project.pbxproj rename AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingFrameworkTests.xcscheme => Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/OS X Tests.xcscheme (92%) rename AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingTests.xcscheme => Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/iOS Tests.xcscheme (88%) rename AFNetworking-Prefix.pch => Tests/AFNetworking-Prefix.pch (100%) rename {AFNetworkingTests => Tests}/AFNetworkingTests-Info.plist (100%) rename {AFNetworkingTests => Tests}/AFNetworkingTests.h (100%) rename {AFNetworkingTests => Tests}/AFNetworkingTests.m (100%) rename Podfile => Tests/Podfile (65%) rename Podfile.lock => Tests/Podfile.lock (100%) diff --git a/.gitignore b/.gitignore index 94ed2b58f0..fad32b8dc6 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ profile *.moved-aside DerivedData .idea/ -Pods +Tests/Pods diff --git a/AFNetworking.xcodeproj/project.pbxproj b/AFNetworking.xcodeproj/project.pbxproj deleted file mode 100644 index b78baa57b9..0000000000 --- a/AFNetworking.xcodeproj/project.pbxproj +++ /dev/null @@ -1,845 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 0BAD1A5426FC47BF8790D245 /* libPods-ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 55E73C267F33406A9F92476C /* libPods-ios.a */; }; - 2544EC36173BE382004117E8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC35173BE382004117E8 /* Foundation.framework */; }; - 2544EC45173BE382004117E8 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC44173BE382004117E8 /* SenTestingKit.framework */; }; - 2544EC47173BE382004117E8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC46173BE382004117E8 /* UIKit.framework */; }; - 2544EC48173BE382004117E8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC35173BE382004117E8 /* Foundation.framework */; }; - 2544EC4B173BE382004117E8 /* libAFNetworking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC32173BE382004117E8 /* libAFNetworking.a */; }; - 2544EC70173BE4DD004117E8 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC5E173BE4DD004117E8 /* AFHTTPClient.m */; }; - 2544EC71173BE4DD004117E8 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC60173BE4DD004117E8 /* AFHTTPRequestOperation.m */; }; - 2544EC72173BE4DD004117E8 /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC62173BE4DD004117E8 /* AFImageRequestOperation.m */; }; - 2544EC73173BE4DD004117E8 /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC64173BE4DD004117E8 /* AFJSONRequestOperation.m */; }; - 2544EC74173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC66173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m */; }; - 2544EC75173BE4DD004117E8 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC69173BE4DD004117E8 /* AFPropertyListRequestOperation.m */; }; - 2544EC76173BE4DD004117E8 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6B173BE4DD004117E8 /* AFURLConnectionOperation.m */; }; - 2544EC77173BE4DD004117E8 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6D173BE4DD004117E8 /* AFXMLRequestOperation.m */; }; - 2544EC78173BE4DD004117E8 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6F173BE4DD004117E8 /* UIImageView+AFNetworking.m */; }; - 2544EC81173BFAA8004117E8 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC80173BFAA8004117E8 /* Cocoa.framework */; }; - 2544EC96173BFAA8004117E8 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC44173BE382004117E8 /* SenTestingKit.framework */; }; - 2544EC97173BFAA8004117E8 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC80173BFAA8004117E8 /* Cocoa.framework */; }; - 2544EC9A173BFAA8004117E8 /* AFNetworkingFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC7F173BFAA8004117E8 /* AFNetworkingFramework.framework */; }; - 25C4EC0E173D74170083E116 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC5E173BE4DD004117E8 /* AFHTTPClient.m */; }; - 25C4EC10173D74170083E116 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC60173BE4DD004117E8 /* AFHTTPRequestOperation.m */; }; - 25C4EC12173D74170083E116 /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC62173BE4DD004117E8 /* AFImageRequestOperation.m */; }; - 25C4EC14173D74170083E116 /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC64173BE4DD004117E8 /* AFJSONRequestOperation.m */; }; - 25C4EC16173D74170083E116 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC66173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m */; }; - 25C4EC19173D74170083E116 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC69173BE4DD004117E8 /* AFPropertyListRequestOperation.m */; }; - 25C4EC1B173D74170083E116 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6B173BE4DD004117E8 /* AFURLConnectionOperation.m */; }; - 25C4EC1D173D74170083E116 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6D173BE4DD004117E8 /* AFXMLRequestOperation.m */; }; - 25C4EC1F173D74170083E116 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 2544EC6F173BE4DD004117E8 /* UIImageView+AFNetworking.m */; }; - 25C4EC20173D7A2D0083E116 /* AFHTTPClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC5D173BE4DD004117E8 /* AFHTTPClient.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 25C4EC21173D7A3C0083E116 /* AFHTTPRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC5F173BE4DD004117E8 /* AFHTTPRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 25C4EC22173D7A3C0083E116 /* AFImageRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC61173BE4DD004117E8 /* AFImageRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 25C4EC23173D7A3C0083E116 /* AFJSONRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC63173BE4DD004117E8 /* AFJSONRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 25C4EC24173D7A3C0083E116 /* AFNetworkActivityIndicatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC65173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 25C4EC25173D7A3C0083E116 /* AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC67173BE4DD004117E8 /* AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 25C4EC26173D7A3C0083E116 /* AFPropertyListRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC68173BE4DD004117E8 /* AFPropertyListRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 25C4EC27173D7A3C0083E116 /* AFURLConnectionOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC6A173BE4DD004117E8 /* AFURLConnectionOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 25C4EC28173D7A3C0083E116 /* AFXMLRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC6C173BE4DD004117E8 /* AFXMLRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 25C4EC29173D7A3C0083E116 /* UIImageView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 2544EC6E173BE4DD004117E8 /* UIImageView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 25C4EC2B173D7DB30083E116 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC2A173D7DB30083E116 /* SystemConfiguration.framework */; }; - 25C4EC2D173D7DBA0083E116 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC2C173D7DBA0083E116 /* CoreServices.framework */; }; - 25C4EC2F173D7DC40083E116 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC2E173D7DC40083E116 /* CFNetwork.framework */; }; - 25C4EC31173D7DCA0083E116 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */; }; - 25C4EC33173D7DD20083E116 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */; }; - 25C4EC36173D7F3C0083E116 /* AFHTTPClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC35173D7F3C0083E116 /* AFHTTPClientTest.m */; }; - 25C4EC37173D7F3C0083E116 /* AFHTTPClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC35173D7F3C0083E116 /* AFHTTPClientTest.m */; }; - 25C4EC3B173D82290083E116 /* AFNetworkingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC3A173D82290083E116 /* AFNetworkingTests.m */; }; - 25C4EC3C173D82290083E116 /* AFNetworkingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC3A173D82290083E116 /* AFNetworkingTests.m */; }; - 25C4EC3F173D84C70083E116 /* AFHTTPRequestOperationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC3E173D84C70083E116 /* AFHTTPRequestOperationTest.m */; }; - 25C4EC40173D84C70083E116 /* AFHTTPRequestOperationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25C4EC3E173D84C70083E116 /* AFHTTPRequestOperationTest.m */; }; - 25C4EC41173D86AE0083E116 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */; }; - 25C4EC42173D86B60083E116 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */; }; - 8C3F274EB4534B2EA29AB3D6 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B6D24F8E1B74E10A269E8B3 /* libPods.a */; }; - AC11A74923B64A3096ACADFC /* libPods-osx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A923755B00464187DEDBAF /* libPods-osx.a */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 2544EC49173BE382004117E8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 2544EC2A173BE382004117E8 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 2544EC31173BE382004117E8; - remoteInfo = AFNetworking; - }; - 2544EC98173BFAA8004117E8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 2544EC2A173BE382004117E8 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 2544EC7E173BFAA8004117E8; - remoteInfo = AFNetworkingFramework; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 2544EC30173BE382004117E8 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/${PRODUCT_NAME}"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 2544EC32173BE382004117E8 /* libAFNetworking.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAFNetworking.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 2544EC35173BE382004117E8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 2544EC43173BE382004117E8 /* AFNetworkingTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AFNetworkingTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; - 2544EC44173BE382004117E8 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; - 2544EC46173BE382004117E8 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; - 2544EC5D173BE4DD004117E8 /* AFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPClient.h; sourceTree = ""; }; - 2544EC5E173BE4DD004117E8 /* AFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClient.m; sourceTree = ""; }; - 2544EC5F173BE4DD004117E8 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = ""; }; - 2544EC60173BE4DD004117E8 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = ""; }; - 2544EC61173BE4DD004117E8 /* AFImageRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFImageRequestOperation.h; sourceTree = ""; }; - 2544EC62173BE4DD004117E8 /* AFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFImageRequestOperation.m; sourceTree = ""; }; - 2544EC63173BE4DD004117E8 /* AFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFJSONRequestOperation.h; sourceTree = ""; }; - 2544EC64173BE4DD004117E8 /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFJSONRequestOperation.m; sourceTree = ""; }; - 2544EC65173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkActivityIndicatorManager.h; sourceTree = ""; }; - 2544EC66173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkActivityIndicatorManager.m; sourceTree = ""; }; - 2544EC67173BE4DD004117E8 /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworking.h; sourceTree = ""; }; - 2544EC68173BE4DD004117E8 /* AFPropertyListRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFPropertyListRequestOperation.h; sourceTree = ""; }; - 2544EC69173BE4DD004117E8 /* AFPropertyListRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFPropertyListRequestOperation.m; sourceTree = ""; }; - 2544EC6A173BE4DD004117E8 /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLConnectionOperation.h; sourceTree = ""; }; - 2544EC6B173BE4DD004117E8 /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLConnectionOperation.m; sourceTree = ""; }; - 2544EC6C173BE4DD004117E8 /* AFXMLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFXMLRequestOperation.h; sourceTree = ""; }; - 2544EC6D173BE4DD004117E8 /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFXMLRequestOperation.m; sourceTree = ""; }; - 2544EC6E173BE4DD004117E8 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+AFNetworking.h"; sourceTree = ""; }; - 2544EC6F173BE4DD004117E8 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+AFNetworking.m"; sourceTree = ""; }; - 2544EC7F173BFAA8004117E8 /* AFNetworkingFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AFNetworkingFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 2544EC80173BFAA8004117E8 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; - 2544EC83173BFAA8004117E8 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; - 2544EC84173BFAA8004117E8 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; - 2544EC85173BFAA8004117E8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 2544EC95173BFAA8004117E8 /* AFNetworkingFrameworkTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AFNetworkingFrameworkTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; - 25C4EC00173BFBA70083E116 /* AFNetworkingTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "AFNetworkingTests-Info.plist"; sourceTree = ""; }; - 25C4EC2A173D7DB30083E116 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; - 25C4EC2C173D7DBA0083E116 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CoreServices.framework; sourceTree = DEVELOPER_DIR; }; - 25C4EC2E173D7DC40083E116 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; - 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; - 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; - 25C4EC35173D7F3C0083E116 /* AFHTTPClientTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClientTest.m; sourceTree = ""; }; - 25C4EC39173D7F9E0083E116 /* AFNetworkingTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AFNetworkingTests.h; sourceTree = ""; }; - 25C4EC3A173D82290083E116 /* AFNetworkingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkingTests.m; sourceTree = ""; }; - 25C4EC3E173D84C70083E116 /* AFHTTPRequestOperationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperationTest.m; sourceTree = ""; }; - 2B6D24F8E1B74E10A269E8B3 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 3A9F6CCEA1634087A54CA260 /* Pods-osx.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-osx.xcconfig"; path = "Pods/Pods-osx.xcconfig"; sourceTree = SOURCE_ROOT; }; - 4185EE53DF5646419AE66CA0 /* Pods-ios.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios.xcconfig"; path = "Pods/Pods-ios.xcconfig"; sourceTree = SOURCE_ROOT; }; - 55E73C267F33406A9F92476C /* libPods-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 96A923755B00464187DEDBAF /* libPods-osx.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-osx.a"; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 2544EC2F173BE382004117E8 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 25C4EC33173D7DD20083E116 /* SystemConfiguration.framework in Frameworks */, - 25C4EC31173D7DCA0083E116 /* MobileCoreServices.framework in Frameworks */, - 25C4EC2F173D7DC40083E116 /* CFNetwork.framework in Frameworks */, - 2544EC36173BE382004117E8 /* Foundation.framework in Frameworks */, - 8C3F274EB4534B2EA29AB3D6 /* libPods.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2544EC3F173BE382004117E8 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 25C4EC42173D86B60083E116 /* MobileCoreServices.framework in Frameworks */, - 25C4EC41173D86AE0083E116 /* SystemConfiguration.framework in Frameworks */, - 2544EC45173BE382004117E8 /* SenTestingKit.framework in Frameworks */, - 2544EC47173BE382004117E8 /* UIKit.framework in Frameworks */, - 2544EC48173BE382004117E8 /* Foundation.framework in Frameworks */, - 2544EC4B173BE382004117E8 /* libAFNetworking.a in Frameworks */, - 0BAD1A5426FC47BF8790D245 /* libPods-ios.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2544EC7B173BFAA8004117E8 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 25C4EC2D173D7DBA0083E116 /* CoreServices.framework in Frameworks */, - 25C4EC2B173D7DB30083E116 /* SystemConfiguration.framework in Frameworks */, - 2544EC81173BFAA8004117E8 /* Cocoa.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2544EC91173BFAA8004117E8 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 2544EC96173BFAA8004117E8 /* SenTestingKit.framework in Frameworks */, - 2544EC97173BFAA8004117E8 /* Cocoa.framework in Frameworks */, - 2544EC9A173BFAA8004117E8 /* AFNetworkingFramework.framework in Frameworks */, - AC11A74923B64A3096ACADFC /* libPods-osx.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 2544EC29173BE382004117E8 = { - isa = PBXGroup; - children = ( - 2544EC37173BE382004117E8 /* AFNetworking */, - 25C4EBFF173BFBA70083E116 /* AFNetworkingTests */, - 2544EC34173BE382004117E8 /* Frameworks */, - 2544EC33173BE382004117E8 /* Products */, - ); - sourceTree = ""; - }; - 2544EC33173BE382004117E8 /* Products */ = { - isa = PBXGroup; - children = ( - 2544EC32173BE382004117E8 /* libAFNetworking.a */, - 2544EC43173BE382004117E8 /* AFNetworkingTests.octest */, - 2544EC7F173BFAA8004117E8 /* AFNetworkingFramework.framework */, - 2544EC95173BFAA8004117E8 /* AFNetworkingFrameworkTests.octest */, - ); - name = Products; - sourceTree = ""; - }; - 2544EC34173BE382004117E8 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */, - 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */, - 25C4EC2E173D7DC40083E116 /* CFNetwork.framework */, - 25C4EC2C173D7DBA0083E116 /* CoreServices.framework */, - 25C4EC2A173D7DB30083E116 /* SystemConfiguration.framework */, - 2544EC35173BE382004117E8 /* Foundation.framework */, - 2544EC44173BE382004117E8 /* SenTestingKit.framework */, - 2544EC46173BE382004117E8 /* UIKit.framework */, - 2544EC80173BFAA8004117E8 /* Cocoa.framework */, - 2544EC82173BFAA8004117E8 /* Other Frameworks */, - 55E73C267F33406A9F92476C /* libPods-ios.a */, - 96A923755B00464187DEDBAF /* libPods-osx.a */, - 2B6D24F8E1B74E10A269E8B3 /* libPods.a */, - ); - name = Frameworks; - sourceTree = ""; - }; - 2544EC37173BE382004117E8 /* AFNetworking */ = { - isa = PBXGroup; - children = ( - 2544EC5D173BE4DD004117E8 /* AFHTTPClient.h */, - 2544EC5E173BE4DD004117E8 /* AFHTTPClient.m */, - 2544EC5F173BE4DD004117E8 /* AFHTTPRequestOperation.h */, - 2544EC60173BE4DD004117E8 /* AFHTTPRequestOperation.m */, - 2544EC61173BE4DD004117E8 /* AFImageRequestOperation.h */, - 2544EC62173BE4DD004117E8 /* AFImageRequestOperation.m */, - 2544EC63173BE4DD004117E8 /* AFJSONRequestOperation.h */, - 2544EC64173BE4DD004117E8 /* AFJSONRequestOperation.m */, - 2544EC65173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.h */, - 2544EC66173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m */, - 2544EC67173BE4DD004117E8 /* AFNetworking.h */, - 2544EC68173BE4DD004117E8 /* AFPropertyListRequestOperation.h */, - 2544EC69173BE4DD004117E8 /* AFPropertyListRequestOperation.m */, - 2544EC6A173BE4DD004117E8 /* AFURLConnectionOperation.h */, - 2544EC6B173BE4DD004117E8 /* AFURLConnectionOperation.m */, - 2544EC6C173BE4DD004117E8 /* AFXMLRequestOperation.h */, - 2544EC6D173BE4DD004117E8 /* AFXMLRequestOperation.m */, - 2544EC6E173BE4DD004117E8 /* UIImageView+AFNetworking.h */, - 2544EC6F173BE4DD004117E8 /* UIImageView+AFNetworking.m */, - ); - path = AFNetworking; - sourceTree = ""; - }; - 2544EC82173BFAA8004117E8 /* Other Frameworks */ = { - isa = PBXGroup; - children = ( - 2544EC83173BFAA8004117E8 /* AppKit.framework */, - 2544EC84173BFAA8004117E8 /* CoreData.framework */, - 2544EC85173BFAA8004117E8 /* Foundation.framework */, - ); - name = "Other Frameworks"; - sourceTree = ""; - }; - 25C4EBFF173BFBA70083E116 /* AFNetworkingTests */ = { - isa = PBXGroup; - children = ( - 25C4EC3E173D84C70083E116 /* AFHTTPRequestOperationTest.m */, - 25C4EC35173D7F3C0083E116 /* AFHTTPClientTest.m */, - 25C4EC39173D7F9E0083E116 /* AFNetworkingTests.h */, - 25C4EC3A173D82290083E116 /* AFNetworkingTests.m */, - 25C4EC38173D7F5A0083E116 /* Support */, - ); - path = AFNetworkingTests; - sourceTree = ""; - }; - 25C4EC38173D7F5A0083E116 /* Support */ = { - isa = PBXGroup; - children = ( - 4185EE53DF5646419AE66CA0 /* Pods-ios.xcconfig */, - 3A9F6CCEA1634087A54CA260 /* Pods-osx.xcconfig */, - 25C4EC00173BFBA70083E116 /* AFNetworkingTests-Info.plist */, - ); - name = Support; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 2544EC7C173BFAA8004117E8 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 25C4EC20173D7A2D0083E116 /* AFHTTPClient.h in Headers */, - 25C4EC21173D7A3C0083E116 /* AFHTTPRequestOperation.h in Headers */, - 25C4EC22173D7A3C0083E116 /* AFImageRequestOperation.h in Headers */, - 25C4EC23173D7A3C0083E116 /* AFJSONRequestOperation.h in Headers */, - 25C4EC24173D7A3C0083E116 /* AFNetworkActivityIndicatorManager.h in Headers */, - 25C4EC25173D7A3C0083E116 /* AFNetworking.h in Headers */, - 25C4EC26173D7A3C0083E116 /* AFPropertyListRequestOperation.h in Headers */, - 25C4EC27173D7A3C0083E116 /* AFURLConnectionOperation.h in Headers */, - 25C4EC28173D7A3C0083E116 /* AFXMLRequestOperation.h in Headers */, - 25C4EC29173D7A3C0083E116 /* UIImageView+AFNetworking.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 2544EC31173BE382004117E8 /* AFNetworking */ = { - isa = PBXNativeTarget; - buildConfigurationList = 2544EC57173BE382004117E8 /* Build configuration list for PBXNativeTarget "AFNetworking" */; - buildPhases = ( - 2544EC2E173BE382004117E8 /* Sources */, - 2544EC2F173BE382004117E8 /* Frameworks */, - 2544EC30173BE382004117E8 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = AFNetworking; - productName = AFNetworking; - productReference = 2544EC32173BE382004117E8 /* libAFNetworking.a */; - productType = "com.apple.product-type.library.static"; - }; - 2544EC42173BE382004117E8 /* AFNetworkingTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 2544EC5A173BE382004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingTests" */; - buildPhases = ( - A56DF943F839492A82A2E686 /* Check Pods Manifest.lock */, - 2544EC3E173BE382004117E8 /* Sources */, - 2544EC3F173BE382004117E8 /* Frameworks */, - 2544EC40173BE382004117E8 /* Resources */, - 2544EC41173BE382004117E8 /* ShellScript */, - B64BACD31A5E4E469B8FA901 /* Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 2544EC4A173BE382004117E8 /* PBXTargetDependency */, - ); - name = AFNetworkingTests; - productName = AFNetworkingTests; - productReference = 2544EC43173BE382004117E8 /* AFNetworkingTests.octest */; - productType = "com.apple.product-type.bundle"; - }; - 2544EC7E173BFAA8004117E8 /* AFNetworkingFramework */ = { - isa = PBXNativeTarget; - buildConfigurationList = 2544ECA4173BFAA8004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingFramework" */; - buildPhases = ( - 2544EC7A173BFAA8004117E8 /* Sources */, - 2544EC7B173BFAA8004117E8 /* Frameworks */, - 2544EC7C173BFAA8004117E8 /* Headers */, - 2544EC7D173BFAA8004117E8 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = AFNetworkingFramework; - productName = AFNetworkingFramework; - productReference = 2544EC7F173BFAA8004117E8 /* AFNetworkingFramework.framework */; - productType = "com.apple.product-type.framework"; - }; - 2544EC94173BFAA8004117E8 /* AFNetworkingFrameworkTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 2544ECA7173BFAA8004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingFrameworkTests" */; - buildPhases = ( - B5A6770A8EDC4CF7A709C8BD /* Check Pods Manifest.lock */, - 2544EC90173BFAA8004117E8 /* Sources */, - 2544EC91173BFAA8004117E8 /* Frameworks */, - 2544EC92173BFAA8004117E8 /* Resources */, - 2544EC93173BFAA8004117E8 /* ShellScript */, - B72AAA1CF47A4D7CAF8BEB66 /* Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 2544EC99173BFAA8004117E8 /* PBXTargetDependency */, - ); - name = AFNetworkingFrameworkTests; - productName = AFNetworkingFrameworkTests; - productReference = 2544EC95173BFAA8004117E8 /* AFNetworkingFrameworkTests.octest */; - productType = "com.apple.product-type.bundle"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 2544EC2A173BE382004117E8 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0460; - ORGANIZATIONNAME = AFNetworking; - }; - buildConfigurationList = 2544EC2D173BE382004117E8 /* Build configuration list for PBXProject "AFNetworking" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 2544EC29173BE382004117E8; - productRefGroup = 2544EC33173BE382004117E8 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 2544EC31173BE382004117E8 /* AFNetworking */, - 2544EC42173BE382004117E8 /* AFNetworkingTests */, - 2544EC7E173BFAA8004117E8 /* AFNetworkingFramework */, - 2544EC94173BFAA8004117E8 /* AFNetworkingFrameworkTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 2544EC40173BE382004117E8 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2544EC7D173BFAA8004117E8 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2544EC92173BFAA8004117E8 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 2544EC41173BE382004117E8 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - }; - 2544EC93173BFAA8004117E8 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - }; - A56DF943F839492A82A2E686 /* Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Check Pods Manifest.lock"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; - }; - B5A6770A8EDC4CF7A709C8BD /* Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Check Pods Manifest.lock"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; - }; - B64BACD31A5E4E469B8FA901 /* Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Pods-ios-resources.sh\"\n"; - }; - B72AAA1CF47A4D7CAF8BEB66 /* Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Pods-osx-resources.sh\"\n"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 2544EC2E173BE382004117E8 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 2544EC70173BE4DD004117E8 /* AFHTTPClient.m in Sources */, - 2544EC71173BE4DD004117E8 /* AFHTTPRequestOperation.m in Sources */, - 2544EC72173BE4DD004117E8 /* AFImageRequestOperation.m in Sources */, - 2544EC73173BE4DD004117E8 /* AFJSONRequestOperation.m in Sources */, - 2544EC74173BE4DD004117E8 /* AFNetworkActivityIndicatorManager.m in Sources */, - 2544EC75173BE4DD004117E8 /* AFPropertyListRequestOperation.m in Sources */, - 2544EC76173BE4DD004117E8 /* AFURLConnectionOperation.m in Sources */, - 2544EC77173BE4DD004117E8 /* AFXMLRequestOperation.m in Sources */, - 2544EC78173BE4DD004117E8 /* UIImageView+AFNetworking.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2544EC3E173BE382004117E8 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 25C4EC36173D7F3C0083E116 /* AFHTTPClientTest.m in Sources */, - 25C4EC3B173D82290083E116 /* AFNetworkingTests.m in Sources */, - 25C4EC3F173D84C70083E116 /* AFHTTPRequestOperationTest.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2544EC7A173BFAA8004117E8 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 25C4EC0E173D74170083E116 /* AFHTTPClient.m in Sources */, - 25C4EC10173D74170083E116 /* AFHTTPRequestOperation.m in Sources */, - 25C4EC12173D74170083E116 /* AFImageRequestOperation.m in Sources */, - 25C4EC14173D74170083E116 /* AFJSONRequestOperation.m in Sources */, - 25C4EC16173D74170083E116 /* AFNetworkActivityIndicatorManager.m in Sources */, - 25C4EC19173D74170083E116 /* AFPropertyListRequestOperation.m in Sources */, - 25C4EC1B173D74170083E116 /* AFURLConnectionOperation.m in Sources */, - 25C4EC1D173D74170083E116 /* AFXMLRequestOperation.m in Sources */, - 25C4EC1F173D74170083E116 /* UIImageView+AFNetworking.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2544EC90173BFAA8004117E8 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 25C4EC37173D7F3C0083E116 /* AFHTTPClientTest.m in Sources */, - 25C4EC3C173D82290083E116 /* AFNetworkingTests.m in Sources */, - 25C4EC40173D84C70083E116 /* AFHTTPRequestOperationTest.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 2544EC4A173BE382004117E8 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 2544EC31173BE382004117E8 /* AFNetworking */; - targetProxy = 2544EC49173BE382004117E8 /* PBXContainerItemProxy */; - }; - 2544EC99173BFAA8004117E8 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 2544EC7E173BFAA8004117E8 /* AFNetworkingFramework */; - targetProxy = 2544EC98173BFAA8004117E8 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 2544EC55173BE382004117E8 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 6.1; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - 2544EC56173BE382004117E8 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 6.1; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 2544EC58173BE382004117E8 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - DSTROOT = /tmp/AFNetworking.dst; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 2544EC59173BE382004117E8 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - DSTROOT = /tmp/AFNetworking.dst; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Release; - }; - 2544EC5B173BE382004117E8 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 4185EE53DF5646419AE66CA0 /* Pods-ios.xcconfig */; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "\"$(SDKROOT)/Developer/Library/Frameworks\"", - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", - ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; - INFOPLIST_FILE = "AFNetworkingTests/AFNetworkingTests-Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = octest; - }; - name = Debug; - }; - 2544EC5C173BE382004117E8 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 4185EE53DF5646419AE66CA0 /* Pods-ios.xcconfig */; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "\"$(SDKROOT)/Developer/Library/Frameworks\"", - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", - ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; - INFOPLIST_FILE = "AFNetworkingTests/AFNetworkingTests-Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = octest; - }; - name = Release; - }; - 2544ECA5173BFAA8004117E8 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - COMBINE_HIDPI_IMAGES = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Library/Frameworks\"", - ); - FRAMEWORK_VERSION = A; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - MACOSX_DEPLOYMENT_TARGET = 10.7; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - WRAPPER_EXTENSION = framework; - }; - name = Debug; - }; - 2544ECA6173BFAA8004117E8 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - COMBINE_HIDPI_IMAGES = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Library/Frameworks\"", - ); - FRAMEWORK_VERSION = A; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - MACOSX_DEPLOYMENT_TARGET = 10.7; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - WRAPPER_EXTENSION = framework; - }; - name = Release; - }; - 2544ECA8173BFAA8004117E8 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 3A9F6CCEA1634087A54CA260 /* Pods-osx.xcconfig */; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - COMBINE_HIDPI_IMAGES = YES; - FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - INFOPLIST_FILE = "AFNetworkingTests/AFNetworkingTests-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.8; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - WRAPPER_EXTENSION = octest; - }; - name = Debug; - }; - 2544ECA9173BFAA8004117E8 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 3A9F6CCEA1634087A54CA260 /* Pods-osx.xcconfig */; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - COMBINE_HIDPI_IMAGES = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - INFOPLIST_FILE = "AFNetworkingTests/AFNetworkingTests-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.8; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - WRAPPER_EXTENSION = octest; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 2544EC2D173BE382004117E8 /* Build configuration list for PBXProject "AFNetworking" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2544EC55173BE382004117E8 /* Debug */, - 2544EC56173BE382004117E8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 2544EC57173BE382004117E8 /* Build configuration list for PBXNativeTarget "AFNetworking" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2544EC58173BE382004117E8 /* Debug */, - 2544EC59173BE382004117E8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 2544EC5A173BE382004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2544EC5B173BE382004117E8 /* Debug */, - 2544EC5C173BE382004117E8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 2544ECA4173BFAA8004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingFramework" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2544ECA5173BFAA8004117E8 /* Debug */, - 2544ECA6173BFAA8004117E8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 2544ECA7173BFAA8004117E8 /* Build configuration list for PBXNativeTarget "AFNetworkingFrameworkTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2544ECA8173BFAA8004117E8 /* Debug */, - 2544ECA9173BFAA8004117E8 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 2544EC2A173BE382004117E8 /* Project object */; -} diff --git a/AFNetworking.xcworkspace/contents.xcworkspacedata b/AFNetworking.xcworkspace/contents.xcworkspacedata index 5608804766..b09daf4bb1 100644 --- a/AFNetworking.xcworkspace/contents.xcworkspacedata +++ b/AFNetworking.xcworkspace/contents.xcworkspacedata @@ -1 +1,16 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/AFNetworkingTests/AFHTTPClientTest.m b/Tests/AFHTTPClientTest.m similarity index 100% rename from AFNetworkingTests/AFHTTPClientTest.m rename to Tests/AFHTTPClientTest.m diff --git a/AFNetworkingTests/AFHTTPRequestOperationTest.m b/Tests/AFHTTPRequestOperationTest.m similarity index 100% rename from AFNetworkingTests/AFHTTPRequestOperationTest.m rename to Tests/AFHTTPRequestOperationTest.m diff --git a/Tests/AFNetworking Tests.xcodeproj/project.pbxproj b/Tests/AFNetworking Tests.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..5a808bec11 --- /dev/null +++ b/Tests/AFNetworking Tests.xcodeproj/project.pbxproj @@ -0,0 +1,517 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0BAD1A5426FC47BF8790D245 /* libPods-ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 55E73C267F33406A9F92476C /* libPods-ios.a */; }; + 2544EC45173BE382004117E8 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC44173BE382004117E8 /* SenTestingKit.framework */; }; + 2544EC47173BE382004117E8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC46173BE382004117E8 /* UIKit.framework */; }; + 2544EC48173BE382004117E8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC35173BE382004117E8 /* Foundation.framework */; }; + 2544EC96173BFAA8004117E8 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC44173BE382004117E8 /* SenTestingKit.framework */; }; + 2544EC97173BFAA8004117E8 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC80173BFAA8004117E8 /* Cocoa.framework */; }; + 25801540173EB3A70026AA6E /* AFHTTPClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153A173EB3A70026AA6E /* AFHTTPClientTest.m */; }; + 25801541173EB3A70026AA6E /* AFHTTPClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153A173EB3A70026AA6E /* AFHTTPClientTest.m */; }; + 25801542173EB3A70026AA6E /* AFHTTPRequestOperationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTest.m */; }; + 25801543173EB3A70026AA6E /* AFHTTPRequestOperationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTest.m */; }; + 25801546173EB3A70026AA6E /* AFNetworkingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153F173EB3A70026AA6E /* AFNetworkingTests.m */; }; + 25801547173EB3A70026AA6E /* AFNetworkingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153F173EB3A70026AA6E /* AFNetworkingTests.m */; }; + 25C4EC41173D86AE0083E116 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */; }; + 25C4EC42173D86B60083E116 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */; }; + 25DE600E173EB13C00422571 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE5FFC173EB13C00422571 /* AFHTTPClient.m */; }; + 25DE600F173EB13C00422571 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE5FFC173EB13C00422571 /* AFHTTPClient.m */; }; + 25DE6010173EB13C00422571 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE5FFE173EB13C00422571 /* AFHTTPRequestOperation.m */; }; + 25DE6011173EB13C00422571 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE5FFE173EB13C00422571 /* AFHTTPRequestOperation.m */; }; + 25DE6012173EB13C00422571 /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE6000173EB13C00422571 /* AFImageRequestOperation.m */; }; + 25DE6013173EB13C00422571 /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE6000173EB13C00422571 /* AFImageRequestOperation.m */; }; + 25DE6014173EB13C00422571 /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE6002173EB13C00422571 /* AFJSONRequestOperation.m */; }; + 25DE6015173EB13C00422571 /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE6002173EB13C00422571 /* AFJSONRequestOperation.m */; }; + 25DE6016173EB13C00422571 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE6004173EB13C00422571 /* AFNetworkActivityIndicatorManager.m */; }; + 25DE6017173EB13C00422571 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE6004173EB13C00422571 /* AFNetworkActivityIndicatorManager.m */; }; + 25DE6018173EB13C00422571 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE6007173EB13C00422571 /* AFPropertyListRequestOperation.m */; }; + 25DE6019173EB13C00422571 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE6007173EB13C00422571 /* AFPropertyListRequestOperation.m */; }; + 25DE601A173EB13C00422571 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE6009173EB13C00422571 /* AFURLConnectionOperation.m */; }; + 25DE601B173EB13C00422571 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE6009173EB13C00422571 /* AFURLConnectionOperation.m */; }; + 25DE601C173EB13C00422571 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE600B173EB13C00422571 /* AFXMLRequestOperation.m */; }; + 25DE601D173EB13C00422571 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE600B173EB13C00422571 /* AFXMLRequestOperation.m */; }; + 25DE601E173EB13C00422571 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE600D173EB13C00422571 /* UIImageView+AFNetworking.m */; }; + 25DE601F173EB13C00422571 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE600D173EB13C00422571 /* UIImageView+AFNetworking.m */; }; + AC11A74923B64A3096ACADFC /* libPods-osx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A923755B00464187DEDBAF /* libPods-osx.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 2544EC35173BE382004117E8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 2544EC43173BE382004117E8 /* iOS Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "iOS Tests.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2544EC44173BE382004117E8 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; + 2544EC46173BE382004117E8 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + 2544EC80173BFAA8004117E8 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; + 2544EC83173BFAA8004117E8 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; + 2544EC84173BFAA8004117E8 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + 2544EC85173BFAA8004117E8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 2544EC95173BFAA8004117E8 /* OS X Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "OS X Tests.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2580153A173EB3A70026AA6E /* AFHTTPClientTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClientTest.m; sourceTree = ""; }; + 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperationTest.m; sourceTree = ""; }; + 2580153E173EB3A70026AA6E /* AFNetworkingTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkingTests.h; sourceTree = ""; }; + 2580153F173EB3A70026AA6E /* AFNetworkingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkingTests.m; sourceTree = ""; }; + 25801549173EB4B40026AA6E /* Pods-ios.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Pods-ios.xcconfig"; path = "Pods/Pods-ios.xcconfig"; sourceTree = ""; }; + 2580154A173EB4B40026AA6E /* Pods-osx.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Pods-osx.xcconfig"; path = "Pods/Pods-osx.xcconfig"; sourceTree = ""; }; + 25C4EC2A173D7DB30083E116 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; + 25C4EC2C173D7DBA0083E116 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CoreServices.framework; sourceTree = DEVELOPER_DIR; }; + 25C4EC2E173D7DC40083E116 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; + 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; + 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + 25DE5FFB173EB13C00422571 /* AFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPClient.h; sourceTree = ""; }; + 25DE5FFC173EB13C00422571 /* AFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClient.m; sourceTree = ""; }; + 25DE5FFD173EB13C00422571 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = ""; }; + 25DE5FFE173EB13C00422571 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = ""; }; + 25DE5FFF173EB13C00422571 /* AFImageRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFImageRequestOperation.h; sourceTree = ""; }; + 25DE6000173EB13C00422571 /* AFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFImageRequestOperation.m; sourceTree = ""; }; + 25DE6001173EB13C00422571 /* AFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFJSONRequestOperation.h; sourceTree = ""; }; + 25DE6002173EB13C00422571 /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFJSONRequestOperation.m; sourceTree = ""; }; + 25DE6003173EB13C00422571 /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkActivityIndicatorManager.h; sourceTree = ""; }; + 25DE6004173EB13C00422571 /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkActivityIndicatorManager.m; sourceTree = ""; }; + 25DE6005173EB13C00422571 /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworking.h; sourceTree = ""; }; + 25DE6006173EB13C00422571 /* AFPropertyListRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFPropertyListRequestOperation.h; sourceTree = ""; }; + 25DE6007173EB13C00422571 /* AFPropertyListRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFPropertyListRequestOperation.m; sourceTree = ""; }; + 25DE6008173EB13C00422571 /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLConnectionOperation.h; sourceTree = ""; }; + 25DE6009173EB13C00422571 /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLConnectionOperation.m; sourceTree = ""; }; + 25DE600A173EB13C00422571 /* AFXMLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFXMLRequestOperation.h; sourceTree = ""; }; + 25DE600B173EB13C00422571 /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFXMLRequestOperation.m; sourceTree = ""; }; + 25DE600C173EB13C00422571 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+AFNetworking.h"; sourceTree = ""; }; + 25DE600D173EB13C00422571 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+AFNetworking.m"; sourceTree = ""; }; + 2B6D24F8E1B74E10A269E8B3 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 55E73C267F33406A9F92476C /* libPods-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 96A923755B00464187DEDBAF /* libPods-osx.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-osx.a"; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2544EC3F173BE382004117E8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 25C4EC42173D86B60083E116 /* MobileCoreServices.framework in Frameworks */, + 25C4EC41173D86AE0083E116 /* SystemConfiguration.framework in Frameworks */, + 2544EC45173BE382004117E8 /* SenTestingKit.framework in Frameworks */, + 2544EC47173BE382004117E8 /* UIKit.framework in Frameworks */, + 2544EC48173BE382004117E8 /* Foundation.framework in Frameworks */, + 0BAD1A5426FC47BF8790D245 /* libPods-ios.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2544EC91173BFAA8004117E8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2544EC96173BFAA8004117E8 /* SenTestingKit.framework in Frameworks */, + 2544EC97173BFAA8004117E8 /* Cocoa.framework in Frameworks */, + AC11A74923B64A3096ACADFC /* libPods-osx.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2544EC29173BE382004117E8 = { + isa = PBXGroup; + children = ( + 25801549173EB4B40026AA6E /* Pods-ios.xcconfig */, + 2580154A173EB4B40026AA6E /* Pods-osx.xcconfig */, + 25801548173EB3B00026AA6E /* Tests */, + 2544EC37173BE382004117E8 /* AFNetworking */, + 2544EC34173BE382004117E8 /* Frameworks */, + 2544EC33173BE382004117E8 /* Products */, + ); + sourceTree = ""; + }; + 2544EC33173BE382004117E8 /* Products */ = { + isa = PBXGroup; + children = ( + 2544EC43173BE382004117E8 /* iOS Tests.octest */, + 2544EC95173BFAA8004117E8 /* OS X Tests.octest */, + ); + name = Products; + sourceTree = ""; + }; + 2544EC34173BE382004117E8 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */, + 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */, + 25C4EC2E173D7DC40083E116 /* CFNetwork.framework */, + 25C4EC2C173D7DBA0083E116 /* CoreServices.framework */, + 25C4EC2A173D7DB30083E116 /* SystemConfiguration.framework */, + 2544EC35173BE382004117E8 /* Foundation.framework */, + 2544EC44173BE382004117E8 /* SenTestingKit.framework */, + 2544EC46173BE382004117E8 /* UIKit.framework */, + 2544EC80173BFAA8004117E8 /* Cocoa.framework */, + 2544EC82173BFAA8004117E8 /* Other Frameworks */, + 55E73C267F33406A9F92476C /* libPods-ios.a */, + 96A923755B00464187DEDBAF /* libPods-osx.a */, + 2B6D24F8E1B74E10A269E8B3 /* libPods.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + 2544EC37173BE382004117E8 /* AFNetworking */ = { + isa = PBXGroup; + children = ( + 25DE5FFB173EB13C00422571 /* AFHTTPClient.h */, + 25DE5FFC173EB13C00422571 /* AFHTTPClient.m */, + 25DE5FFD173EB13C00422571 /* AFHTTPRequestOperation.h */, + 25DE5FFE173EB13C00422571 /* AFHTTPRequestOperation.m */, + 25DE5FFF173EB13C00422571 /* AFImageRequestOperation.h */, + 25DE6000173EB13C00422571 /* AFImageRequestOperation.m */, + 25DE6001173EB13C00422571 /* AFJSONRequestOperation.h */, + 25DE6002173EB13C00422571 /* AFJSONRequestOperation.m */, + 25DE6003173EB13C00422571 /* AFNetworkActivityIndicatorManager.h */, + 25DE6004173EB13C00422571 /* AFNetworkActivityIndicatorManager.m */, + 25DE6005173EB13C00422571 /* AFNetworking.h */, + 25DE6006173EB13C00422571 /* AFPropertyListRequestOperation.h */, + 25DE6007173EB13C00422571 /* AFPropertyListRequestOperation.m */, + 25DE6008173EB13C00422571 /* AFURLConnectionOperation.h */, + 25DE6009173EB13C00422571 /* AFURLConnectionOperation.m */, + 25DE600A173EB13C00422571 /* AFXMLRequestOperation.h */, + 25DE600B173EB13C00422571 /* AFXMLRequestOperation.m */, + 25DE600C173EB13C00422571 /* UIImageView+AFNetworking.h */, + 25DE600D173EB13C00422571 /* UIImageView+AFNetworking.m */, + ); + name = AFNetworking; + path = ../AFNetworking; + sourceTree = ""; + }; + 2544EC82173BFAA8004117E8 /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 2544EC83173BFAA8004117E8 /* AppKit.framework */, + 2544EC84173BFAA8004117E8 /* CoreData.framework */, + 2544EC85173BFAA8004117E8 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 25801548173EB3B00026AA6E /* Tests */ = { + isa = PBXGroup; + children = ( + 2580153A173EB3A70026AA6E /* AFHTTPClientTest.m */, + 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTest.m */, + 2580153E173EB3A70026AA6E /* AFNetworkingTests.h */, + 2580153F173EB3A70026AA6E /* AFNetworkingTests.m */, + ); + name = Tests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2544EC42173BE382004117E8 /* iOS Tests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2544EC5A173BE382004117E8 /* Build configuration list for PBXNativeTarget "iOS Tests" */; + buildPhases = ( + 2544EC3E173BE382004117E8 /* Sources */, + 2544EC3F173BE382004117E8 /* Frameworks */, + 2544EC40173BE382004117E8 /* Resources */, + 2544EC41173BE382004117E8 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "iOS Tests"; + productName = AFNetworkingTests; + productReference = 2544EC43173BE382004117E8 /* iOS Tests.octest */; + productType = "com.apple.product-type.bundle"; + }; + 2544EC94173BFAA8004117E8 /* OS X Tests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2544ECA7173BFAA8004117E8 /* Build configuration list for PBXNativeTarget "OS X Tests" */; + buildPhases = ( + 2544EC90173BFAA8004117E8 /* Sources */, + 2544EC91173BFAA8004117E8 /* Frameworks */, + 2544EC92173BFAA8004117E8 /* Resources */, + 2544EC93173BFAA8004117E8 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "OS X Tests"; + productName = AFNetworkingFrameworkTests; + productReference = 2544EC95173BFAA8004117E8 /* OS X Tests.octest */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2544EC2A173BE382004117E8 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0460; + ORGANIZATIONNAME = AFNetworking; + }; + buildConfigurationList = 2544EC2D173BE382004117E8 /* Build configuration list for PBXProject "AFNetworking Tests" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 2544EC29173BE382004117E8; + productRefGroup = 2544EC33173BE382004117E8 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 2544EC42173BE382004117E8 /* iOS Tests */, + 2544EC94173BFAA8004117E8 /* OS X Tests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 2544EC40173BE382004117E8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2544EC92173BFAA8004117E8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 2544EC41173BE382004117E8 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; + }; + 2544EC93173BFAA8004117E8 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2544EC3E173BE382004117E8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 25DE600E173EB13C00422571 /* AFHTTPClient.m in Sources */, + 25DE6010173EB13C00422571 /* AFHTTPRequestOperation.m in Sources */, + 25DE6012173EB13C00422571 /* AFImageRequestOperation.m in Sources */, + 25DE6014173EB13C00422571 /* AFJSONRequestOperation.m in Sources */, + 25DE6016173EB13C00422571 /* AFNetworkActivityIndicatorManager.m in Sources */, + 25DE6018173EB13C00422571 /* AFPropertyListRequestOperation.m in Sources */, + 25DE601A173EB13C00422571 /* AFURLConnectionOperation.m in Sources */, + 25DE601C173EB13C00422571 /* AFXMLRequestOperation.m in Sources */, + 25DE601E173EB13C00422571 /* UIImageView+AFNetworking.m in Sources */, + 25801540173EB3A70026AA6E /* AFHTTPClientTest.m in Sources */, + 25801542173EB3A70026AA6E /* AFHTTPRequestOperationTest.m in Sources */, + 25801546173EB3A70026AA6E /* AFNetworkingTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2544EC90173BFAA8004117E8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 25DE600F173EB13C00422571 /* AFHTTPClient.m in Sources */, + 25DE6011173EB13C00422571 /* AFHTTPRequestOperation.m in Sources */, + 25DE6013173EB13C00422571 /* AFImageRequestOperation.m in Sources */, + 25DE6015173EB13C00422571 /* AFJSONRequestOperation.m in Sources */, + 25DE6017173EB13C00422571 /* AFNetworkActivityIndicatorManager.m in Sources */, + 25DE6019173EB13C00422571 /* AFPropertyListRequestOperation.m in Sources */, + 25DE601B173EB13C00422571 /* AFURLConnectionOperation.m in Sources */, + 25DE601D173EB13C00422571 /* AFXMLRequestOperation.m in Sources */, + 25DE601F173EB13C00422571 /* UIImageView+AFNetworking.m in Sources */, + 25801541173EB3A70026AA6E /* AFHTTPClientTest.m in Sources */, + 25801543173EB3A70026AA6E /* AFHTTPRequestOperationTest.m in Sources */, + 25801547173EB3A70026AA6E /* AFNetworkingTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 2544EC55173BE382004117E8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 2544EC56173BE382004117E8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 2544EC5B173BE382004117E8 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 25801549173EB4B40026AA6E /* Pods-ios.xcconfig */; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "\"$(SDKROOT)/Developer/Library/Frameworks\"", + "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + INFOPLIST_FILE = "AFNetworkingTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = octest; + }; + name = Debug; + }; + 2544EC5C173BE382004117E8 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 25801549173EB4B40026AA6E /* Pods-ios.xcconfig */; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "\"$(SDKROOT)/Developer/Library/Frameworks\"", + "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + INFOPLIST_FILE = "AFNetworkingTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = octest; + }; + name = Release; + }; + 2544ECA8173BFAA8004117E8 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 2580154A173EB4B40026AA6E /* Pods-osx.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COMBINE_HIDPI_IMAGES = YES; + FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + INFOPLIST_FILE = "AFNetworkingTests-Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.8; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + WRAPPER_EXTENSION = octest; + }; + name = Debug; + }; + 2544ECA9173BFAA8004117E8 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 2580154A173EB4B40026AA6E /* Pods-osx.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AFNetworking-Prefix.pch"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + INFOPLIST_FILE = "AFNetworkingTests-Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.8; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + WRAPPER_EXTENSION = octest; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2544EC2D173BE382004117E8 /* Build configuration list for PBXProject "AFNetworking Tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2544EC55173BE382004117E8 /* Debug */, + 2544EC56173BE382004117E8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2544EC5A173BE382004117E8 /* Build configuration list for PBXNativeTarget "iOS Tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2544EC5B173BE382004117E8 /* Debug */, + 2544EC5C173BE382004117E8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2544ECA7173BFAA8004117E8 /* Build configuration list for PBXNativeTarget "OS X Tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2544ECA8173BFAA8004117E8 /* Debug */, + 2544ECA9173BFAA8004117E8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2544EC2A173BE382004117E8 /* Project object */; +} diff --git a/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingFrameworkTests.xcscheme b/Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/OS X Tests.xcscheme similarity index 92% rename from AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingFrameworkTests.xcscheme rename to Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/OS X Tests.xcscheme index 050ad6dfb4..8dfea57154 100644 --- a/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingFrameworkTests.xcscheme +++ b/Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/OS X Tests.xcscheme @@ -14,7 +14,7 @@ buildForAnalyzing = "YES"> @@ -33,8 +33,8 @@ diff --git a/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingTests.xcscheme b/Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/iOS Tests.xcscheme similarity index 88% rename from AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingTests.xcscheme rename to Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/iOS Tests.xcscheme index 5126d14e99..f5cbe8b0c8 100644 --- a/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworkingTests.xcscheme +++ b/Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/iOS Tests.xcscheme @@ -4,7 +4,7 @@ version = "1.3"> + buildImplicitDependencies = "NO"> @@ -33,9 +33,9 @@ + BuildableName = "iOS Tests.octest" + BlueprintName = "iOS Tests" + ReferencedContainer = "container:AFNetworking Tests.xcodeproj"> diff --git a/AFNetworking-Prefix.pch b/Tests/AFNetworking-Prefix.pch similarity index 100% rename from AFNetworking-Prefix.pch rename to Tests/AFNetworking-Prefix.pch diff --git a/AFNetworkingTests/AFNetworkingTests-Info.plist b/Tests/AFNetworkingTests-Info.plist similarity index 100% rename from AFNetworkingTests/AFNetworkingTests-Info.plist rename to Tests/AFNetworkingTests-Info.plist diff --git a/AFNetworkingTests/AFNetworkingTests.h b/Tests/AFNetworkingTests.h similarity index 100% rename from AFNetworkingTests/AFNetworkingTests.h rename to Tests/AFNetworkingTests.h diff --git a/AFNetworkingTests/AFNetworkingTests.m b/Tests/AFNetworkingTests.m similarity index 100% rename from AFNetworkingTests/AFNetworkingTests.m rename to Tests/AFNetworkingTests.m diff --git a/Podfile b/Tests/Podfile similarity index 65% rename from Podfile rename to Tests/Podfile index 2ab86c14e3..6c587cdfe0 100644 --- a/Podfile +++ b/Tests/Podfile @@ -1,3 +1,5 @@ +xcodeproj 'AFNetworking Tests' +workspace '../AFNetworking' inhibit_all_warnings! def import_pods @@ -7,12 +9,12 @@ end target :ios do platform :ios, '5.0' - link_with 'AFNetworkingTests' + link_with 'iOS Tests' import_pods end target :osx do platform :osx, '10.7' - link_with 'AFNetworkingFrameworkTests' + link_with 'OS X Tests' import_pods end diff --git a/Podfile.lock b/Tests/Podfile.lock similarity index 100% rename from Podfile.lock rename to Tests/Podfile.lock From 91cf441582e60a116558604d5cdb0b4ad0f8ad83 Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Sat, 11 May 2013 13:24:41 -0400 Subject: [PATCH 0188/1434] Restore functionality of Rake tasks --- Rakefile | 12 ++++++------ Tests/AFNetworking Tests.xcodeproj/project.pbxproj | 4 ++++ .../xcshareddata/xcschemes/OS X Tests.xcscheme | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index 5b37a51bb9..48e4611123 100644 --- a/Rakefile +++ b/Rakefile @@ -1,16 +1,16 @@ namespace :test do desc "Run the AFNetworking Tests for iOS" task :ios do - system('xctool -workspace AFNetworking.xcworkspace -scheme AFNetworkingTests test -test-sdk iphonesimulator') + system("xctool -workspace AFNetworking.xcworkspace -scheme 'iOS Tests' test -test-sdk iphonesimulator") end desc "Run the AFNetworking Tests for Mac OS X" task :osx do - system('xctool -workspace AFNetworking.xcworkspace -scheme AFNetworkingFrameworkTests test -test-sdk macosx -sdk macosx') + system("xctool -workspace AFNetworking.xcworkspace -scheme 'OS X Tests' test -test-sdk macosx -sdk macosx") end - - desc "Run the AFNetworking Tests for iOS & Mac OS X" - task :all => ['test:ios', 'test:osx'] end -task :default => 'test:all' +desc "Run the AFNetworking Tests for iOS & Mac OS X" +task :test => ['test:ios', 'test:osx'] + +task :default => 'test' diff --git a/Tests/AFNetworking Tests.xcodeproj/project.pbxproj b/Tests/AFNetworking Tests.xcodeproj/project.pbxproj index 5a808bec11..5e0d05e9b8 100644 --- a/Tests/AFNetworking Tests.xcodeproj/project.pbxproj +++ b/Tests/AFNetworking Tests.xcodeproj/project.pbxproj @@ -19,6 +19,8 @@ 25801543173EB3A70026AA6E /* AFHTTPRequestOperationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTest.m */; }; 25801546173EB3A70026AA6E /* AFNetworkingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153F173EB3A70026AA6E /* AFNetworkingTests.m */; }; 25801547173EB3A70026AA6E /* AFNetworkingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153F173EB3A70026AA6E /* AFNetworkingTests.m */; }; + 2580154B173EB62E0026AA6E /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC2A173D7DB30083E116 /* SystemConfiguration.framework */; }; + 2580154C173EB6340026AA6E /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC2C173D7DBA0083E116 /* CoreServices.framework */; }; 25C4EC41173D86AE0083E116 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC32173D7DD20083E116 /* SystemConfiguration.framework */; }; 25C4EC42173D86B60083E116 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC30173D7DCA0083E116 /* MobileCoreServices.framework */; }; 25DE600E173EB13C00422571 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE5FFC173EB13C00422571 /* AFHTTPClient.m */; }; @@ -105,6 +107,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 2580154C173EB6340026AA6E /* CoreServices.framework in Frameworks */, + 2580154B173EB62E0026AA6E /* SystemConfiguration.framework in Frameworks */, 2544EC96173BFAA8004117E8 /* SenTestingKit.framework in Frameworks */, 2544EC97173BFAA8004117E8 /* Cocoa.framework in Frameworks */, AC11A74923B64A3096ACADFC /* libPods-osx.a in Frameworks */, diff --git a/Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/OS X Tests.xcscheme b/Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/OS X Tests.xcscheme index 8dfea57154..57a00f4d27 100644 --- a/Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/OS X Tests.xcscheme +++ b/Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/OS X Tests.xcscheme @@ -14,7 +14,7 @@ buildForAnalyzing = "YES"> @@ -35,7 +35,7 @@ BlueprintIdentifier = "2544EC94173BFAA8004117E8" BuildableName = "OS X Tests.octest" BlueprintName = "OS X Tests" - ReferencedContainer = "container:AFNetworking.xcodeproj"> + ReferencedContainer = "container:AFNetworking Tests.xcodeproj"> From bb4c19eab61892ad84da081b12931f5bd8682b49 Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Sat, 11 May 2013 13:35:36 -0400 Subject: [PATCH 0189/1434] Add section to the README.md detailing how to setup and execute the unit tests --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 722490688d..de2f414d07 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,21 @@ If you are using AFNetworking 1.0 in your non-arc project, you will need to set To set a compiler flag in Xcode, go to your active target and select the "Build Phases" tab. Now select all AFNetworking source files, press Enter, insert `-fobjc-arc` or `-fno-objc-arc` and then "Done" to enable or disable ARC for AFNetworking. +## Unit Tests + +AFNetworking includes a suite of unit tests within the Tests subdirectory. In order to run the unit tests, you must install the testing dependencies via CocoaPods. To do so: + +1. `gem install cocoapods` # If necessary +1. `cd Tests` +1. `pod install` + +Once CocoaPods has finished the installation, you can execute the test suite via the 'iOS Tests' and 'OS X Tests' schemes within Xcode. If you wish to execute the tests from the command line or within a continuous integration environment, you will need to install [xctool](https://github.com/facebook/xctool). The recommended installation method is [Homebrew](http://mxcl.github.io/homebrew/). To install the commandline testing support via Homebrew: + +1. `brew update` +1. `brew install xctool --HEAD` + +Once xctool is installed, you can execute the suite via `rake test`. + ## Credits AFNetworking was created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla). From fad9a6249c4bfc75250459575214123890475947 Mon Sep 17 00:00:00 2001 From: Daniel Demiss Date: Sun, 12 May 2013 18:26:02 +0300 Subject: [PATCH 0190/1434] Fixed a leak in requestWithMethod:path:parameters: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `CFStringConvertEncodingToIANACharSetName` is documented to follow CF’s create-rule, so the cast needed to be transferring ownership to ARC. --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 6422a56107..3ab130b35e 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -460,7 +460,7 @@ - (NSMutableURLRequest *)requestWithMethod:(NSString *)method url = [NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:[path rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding)]]; [request setURL:url]; } else { - NSString *charset = (__bridge NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding)); + NSString *charset = (__bridge_transfer NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding)); NSError *error = nil; switch (self.parameterEncoding) { From db8a44a9b16dd0edb68185c64d6a19951b684802 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 12 May 2013 19:05:11 -0700 Subject: [PATCH 0191/1434] Revert "Fixed a leak in requestWithMethod:path:parameters:" This reverts commit fad9a6249c4bfc75250459575214123890475947. --- AFNetworking/AFHTTPClient.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 3ab130b35e..6422a56107 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -460,7 +460,7 @@ - (NSMutableURLRequest *)requestWithMethod:(NSString *)method url = [NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:[path rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding)]]; [request setURL:url]; } else { - NSString *charset = (__bridge_transfer NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding)); + NSString *charset = (__bridge NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding)); NSError *error = nil; switch (self.parameterEncoding) { From 5c81d90a4cfe5176a3181357f72c0b8e063b9287 Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Mon, 13 May 2013 09:10:39 -0400 Subject: [PATCH 0192/1434] Add test coverage for construction of request body via `AFHTTPClient`. refs #989 --- Tests/AFHTTPClientTest.m | 24 ------- Tests/AFHTTPClientTests.m | 66 +++++++++++++++++++ ...onTest.m => AFHTTPRequestOperationTests.m} | 6 +- .../project.pbxproj | 24 +++---- 4 files changed, 81 insertions(+), 39 deletions(-) delete mode 100644 Tests/AFHTTPClientTest.m create mode 100644 Tests/AFHTTPClientTests.m rename Tests/{AFHTTPRequestOperationTest.m => AFHTTPRequestOperationTests.m} (91%) diff --git a/Tests/AFHTTPClientTest.m b/Tests/AFHTTPClientTest.m deleted file mode 100644 index 9e041664fb..0000000000 --- a/Tests/AFHTTPClientTest.m +++ /dev/null @@ -1,24 +0,0 @@ -// -// AFHTTPClientTest.m -// AFNetworking -// -// Created by Blake Watters on 5/10/13. -// Copyright (c) 2013 AFNetworking. All rights reserved. -// - -#import "AFNetworkingTests.h" - -@interface AFHTTPClientTest : SenTestCase -@end - -@implementation AFHTTPClientTest - -- (void)testThatTheDefaultStringEncodingIsUTF8 -{ - AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; - expect(client.stringEncoding).to.equal(NSUTF8StringEncoding); -} - -// default value for header - -@end diff --git a/Tests/AFHTTPClientTests.m b/Tests/AFHTTPClientTests.m new file mode 100644 index 0000000000..e7681ed94a --- /dev/null +++ b/Tests/AFHTTPClientTests.m @@ -0,0 +1,66 @@ +// +// AFHTTPClientTests.m +// AFNetworking +// +// Created by Blake Watters on 5/10/13. +// Copyright (c) 2013 AFNetworking. All rights reserved. +// + +#import "AFNetworkingTests.h" + +@interface AFHTTPClientTests : SenTestCase +@end + +@implementation AFHTTPClientTests + +- (void)testThatTheDefaultStringEncodingIsUTF8 +{ + AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; + expect(client.stringEncoding).to.equal(NSUTF8StringEncoding); +} + +- (void)testConstructingPOSTRequestWithParametersInFormURLParameterEncoding +{ + AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; + client.parameterEncoding = AFFormURLParameterEncoding; + NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"/post" parameters:@{ @"key": @"value" }]; + NSString *requestBody = [[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding]; + expect(requestBody).to.equal(@"key=value"); +} + +- (void)testConstructingPOSTRequestWithParametersInJSONParameterEncoding +{ + AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; + client.parameterEncoding = AFJSONParameterEncoding; + NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"/post" parameters:@{ @"key": @"value" }]; + NSString *requestBody = [[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding]; + expect(requestBody).to.equal(@"{\"key\":\"value\"}"); +} + +- (void)testConstructingPOSTRequestWithParametersInPropertyListParameterEncoding +{ + AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; + client.parameterEncoding = AFPropertyListParameterEncoding; + NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"/post" parameters:@{ @"key": @"value" }]; + NSString *requestBody = [[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding]; + expect(requestBody).to.equal(@"\n\n\n\n key\n value\n\n\n"); +} + +- (void)testPostWithParameters +{ + __block id blockResponseObject = nil; + AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; + [client postPath:@"/post" parameters:@{ @"key": @"value" } success:^(AFHTTPRequestOperation *operation, id responseObject) { + blockResponseObject = responseObject; + } failure:nil]; + expect([client.operationQueue operationCount]).will.equal(0); + expect(blockResponseObject).notTo.beNil(); + expect(blockResponseObject).to.beKindOf([NSData class]); + NSError *error = nil; + NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:blockResponseObject options:0 error:&error]; + expect(responseDictionary[@"form"]).to.equal(@{ @"key": @"value" }); +} + +// default value for header + +@end diff --git a/Tests/AFHTTPRequestOperationTest.m b/Tests/AFHTTPRequestOperationTests.m similarity index 91% rename from Tests/AFHTTPRequestOperationTest.m rename to Tests/AFHTTPRequestOperationTests.m index 03771bedb3..afdeb28eb5 100644 --- a/Tests/AFHTTPRequestOperationTest.m +++ b/Tests/AFHTTPRequestOperationTests.m @@ -1,5 +1,5 @@ // -// AFHTTPRequestOperationTest.m +// AFHTTPRequestOperationTests.m // AFNetworking // // Created by Blake Watters on 5/10/13. @@ -8,10 +8,10 @@ #import "AFNetworkingTests.h" -@interface AFHTTPRequestOperationTest : SenTestCase +@interface AFHTTPRequestOperationTests : SenTestCase @end -@implementation AFHTTPRequestOperationTest +@implementation AFHTTPRequestOperationTests - (void)testThatOperationInvokesSuccessCompletionBlockWithResponseObjectOnSuccess { diff --git a/Tests/AFNetworking Tests.xcodeproj/project.pbxproj b/Tests/AFNetworking Tests.xcodeproj/project.pbxproj index 5e0d05e9b8..a16b6cc94e 100644 --- a/Tests/AFNetworking Tests.xcodeproj/project.pbxproj +++ b/Tests/AFNetworking Tests.xcodeproj/project.pbxproj @@ -13,10 +13,10 @@ 2544EC48173BE382004117E8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC35173BE382004117E8 /* Foundation.framework */; }; 2544EC96173BFAA8004117E8 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC44173BE382004117E8 /* SenTestingKit.framework */; }; 2544EC97173BFAA8004117E8 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2544EC80173BFAA8004117E8 /* Cocoa.framework */; }; - 25801540173EB3A70026AA6E /* AFHTTPClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153A173EB3A70026AA6E /* AFHTTPClientTest.m */; }; - 25801541173EB3A70026AA6E /* AFHTTPClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153A173EB3A70026AA6E /* AFHTTPClientTest.m */; }; - 25801542173EB3A70026AA6E /* AFHTTPRequestOperationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTest.m */; }; - 25801543173EB3A70026AA6E /* AFHTTPRequestOperationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTest.m */; }; + 25801540173EB3A70026AA6E /* AFHTTPClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153A173EB3A70026AA6E /* AFHTTPClientTests.m */; }; + 25801541173EB3A70026AA6E /* AFHTTPClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153A173EB3A70026AA6E /* AFHTTPClientTests.m */; }; + 25801542173EB3A70026AA6E /* AFHTTPRequestOperationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTests.m */; }; + 25801543173EB3A70026AA6E /* AFHTTPRequestOperationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTests.m */; }; 25801546173EB3A70026AA6E /* AFNetworkingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153F173EB3A70026AA6E /* AFNetworkingTests.m */; }; 25801547173EB3A70026AA6E /* AFNetworkingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2580153F173EB3A70026AA6E /* AFNetworkingTests.m */; }; 2580154B173EB62E0026AA6E /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25C4EC2A173D7DB30083E116 /* SystemConfiguration.framework */; }; @@ -54,8 +54,8 @@ 2544EC84173BFAA8004117E8 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 2544EC85173BFAA8004117E8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 2544EC95173BFAA8004117E8 /* OS X Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "OS X Tests.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; - 2580153A173EB3A70026AA6E /* AFHTTPClientTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClientTest.m; sourceTree = ""; }; - 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperationTest.m; sourceTree = ""; }; + 2580153A173EB3A70026AA6E /* AFHTTPClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClientTests.m; sourceTree = ""; }; + 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperationTests.m; sourceTree = ""; }; 2580153E173EB3A70026AA6E /* AFNetworkingTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkingTests.h; sourceTree = ""; }; 2580153F173EB3A70026AA6E /* AFNetworkingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkingTests.m; sourceTree = ""; }; 25801549173EB4B40026AA6E /* Pods-ios.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Pods-ios.xcconfig"; path = "Pods/Pods-ios.xcconfig"; sourceTree = ""; }; @@ -199,8 +199,8 @@ 25801548173EB3B00026AA6E /* Tests */ = { isa = PBXGroup; children = ( - 2580153A173EB3A70026AA6E /* AFHTTPClientTest.m */, - 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTest.m */, + 2580153A173EB3A70026AA6E /* AFHTTPClientTests.m */, + 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTests.m */, 2580153E173EB3A70026AA6E /* AFNetworkingTests.h */, 2580153F173EB3A70026AA6E /* AFNetworkingTests.m */, ); @@ -333,8 +333,8 @@ 25DE601A173EB13C00422571 /* AFURLConnectionOperation.m in Sources */, 25DE601C173EB13C00422571 /* AFXMLRequestOperation.m in Sources */, 25DE601E173EB13C00422571 /* UIImageView+AFNetworking.m in Sources */, - 25801540173EB3A70026AA6E /* AFHTTPClientTest.m in Sources */, - 25801542173EB3A70026AA6E /* AFHTTPRequestOperationTest.m in Sources */, + 25801540173EB3A70026AA6E /* AFHTTPClientTests.m in Sources */, + 25801542173EB3A70026AA6E /* AFHTTPRequestOperationTests.m in Sources */, 25801546173EB3A70026AA6E /* AFNetworkingTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -352,8 +352,8 @@ 25DE601B173EB13C00422571 /* AFURLConnectionOperation.m in Sources */, 25DE601D173EB13C00422571 /* AFXMLRequestOperation.m in Sources */, 25DE601F173EB13C00422571 /* UIImageView+AFNetworking.m in Sources */, - 25801541173EB3A70026AA6E /* AFHTTPClientTest.m in Sources */, - 25801543173EB3A70026AA6E /* AFHTTPRequestOperationTest.m in Sources */, + 25801541173EB3A70026AA6E /* AFHTTPClientTests.m in Sources */, + 25801543173EB3A70026AA6E /* AFHTTPRequestOperationTests.m in Sources */, 25801547173EB3A70026AA6E /* AFNetworkingTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; From 6e57c377f17705cc4b09165f04a808c5acbc233a Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Mon, 13 May 2013 09:21:36 -0400 Subject: [PATCH 0193/1434] Add test coverage around operation cancellation setting the error and invoking the failure block. refs #941 --- Tests/AFHTTPRequestOperationTests.m | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Tests/AFHTTPRequestOperationTests.m b/Tests/AFHTTPRequestOperationTests.m index afdeb28eb5..ff5a80c074 100644 --- a/Tests/AFHTTPRequestOperationTests.m +++ b/Tests/AFHTTPRequestOperationTests.m @@ -39,4 +39,30 @@ - (void)testThatOperationInvokesFailureCompletionBlockWithErrorOnFailure expect(blockError).willNot.beNil(); } +- (void)testThatCancellationOfRequestOperationSetsError +{ + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/delay/5" relativeToURL:AFNetworkingTestsBaseURL()]]; + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + [operation start]; + expect([operation isExecuting]).will.beTruthy(); + [operation cancel]; + expect(operation.error).willNot.beNil(); + expect(operation.error.code).to.equal(NSURLErrorCancelled); +} + +- (void)testThatCancellationOfRequestOperationInvokesFailureCompletionBlock +{ + __block NSError *blockError = nil; + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/delay/5" relativeToURL:AFNetworkingTestsBaseURL()]]; + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + [operation setCompletionBlockWithSuccess:nil failure:^(AFHTTPRequestOperation *operation, NSError *error) { + blockError = error; + }]; + [operation start]; + expect([operation isExecuting]).will.beTruthy(); + [operation cancel]; + expect(blockError).willNot.beNil(); + expect(blockError.code).to.equal(NSURLErrorCancelled); +} + @end From 4d8faf8a23c94fa71bed2e80d39e8227eaca0bc8 Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Mon, 13 May 2013 09:25:13 -0400 Subject: [PATCH 0194/1434] Pull in a few more basic request/response tests from @kcharwood --- Tests/AFHTTPRequestOperationTests.m | 53 ++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/Tests/AFHTTPRequestOperationTests.m b/Tests/AFHTTPRequestOperationTests.m index ff5a80c074..029ce9c818 100644 --- a/Tests/AFHTTPRequestOperationTests.m +++ b/Tests/AFHTTPRequestOperationTests.m @@ -29,7 +29,7 @@ - (void)testThatOperationInvokesSuccessCompletionBlockWithResponseObjectOnSucces - (void)testThatOperationInvokesFailureCompletionBlockWithErrorOnFailure { __block NSError *blockError = nil; - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/404" relativeToURL:AFNetworkingTestsBaseURL()]]; + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/status/404" relativeToURL:AFNetworkingTestsBaseURL()]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:nil failure:^(AFHTTPRequestOperation *operation, NSError *error) { blockError = error; @@ -65,4 +65,55 @@ - (void)testThatCancellationOfRequestOperationInvokesFailureCompletionBlock expect(blockError.code).to.equal(NSURLErrorCancelled); } +- (void)testThat500StatusCodeInvokesFailureCompletionBlockWithErrorOnFailure +{ + __block NSError *blockError = nil; + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/status/500" relativeToURL:AFNetworkingTestsBaseURL()]]; + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + [operation setCompletionBlockWithSuccess:nil failure:^(AFHTTPRequestOperation *operation, NSError *error) { + blockError = error; + }]; + [operation start]; + expect([operation isFinished]).will.beTruthy(); + expect(blockError).willNot.beNil(); +} + +- (void)testThatRedirectBlockIsCalledWhen302IsEncountered +{ + __block BOOL success; + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/redirect/1" relativeToURL:AFNetworkingTestsBaseURL()]]; + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + [operation setCompletionBlockWithSuccess:nil + failure:nil]; + [operation + setRedirectResponseBlock:^NSURLRequest *(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse) { + if(redirectResponse){ + success = YES; + } + return request; + }]; + [operation start]; + expect([operation isFinished]).will.beTruthy(); + expect(success).will.beTruthy(); +} + +- (void)testThatRedirectBlockIsCalledMultipleTimesWhen302IsEncountered +{ + __block NSInteger numberOfRedirects = 0; + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/redirect/5" relativeToURL:AFNetworkingTestsBaseURL()]]; + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + [operation setCompletionBlockWithSuccess:nil + failure:nil]; + [operation + setRedirectResponseBlock:^NSURLRequest *(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse) { + if(redirectResponse){ + numberOfRedirects++; + } + return request; + }]; + [operation start]; + expect([operation isFinished]).will.beTruthy(); + expect(numberOfRedirects).will.equal(5); +} + @end From c2c3a656e7e627b2f4353cc3f58fe26c1ed426d6 Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Mon, 13 May 2013 09:31:45 -0400 Subject: [PATCH 0195/1434] Add composite status code reporting during CLI execution --- Rakefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 48e4611123..df32ced28d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,16 +1,24 @@ namespace :test do desc "Run the AFNetworking Tests for iOS" task :ios do - system("xctool -workspace AFNetworking.xcworkspace -scheme 'iOS Tests' test -test-sdk iphonesimulator") + $ios_success = system("xctool -workspace AFNetworking.xcworkspace -scheme 'iOS Tests' test -test-sdk iphonesimulator") end desc "Run the AFNetworking Tests for Mac OS X" task :osx do - system("xctool -workspace AFNetworking.xcworkspace -scheme 'OS X Tests' test -test-sdk macosx -sdk macosx") + $osx_success = system("xctool -workspace AFNetworking.xcworkspace -scheme 'OS X Tests' test -test-sdk macosx -sdk macosx") end end desc "Run the AFNetworking Tests for iOS & Mac OS X" -task :test => ['test:ios', 'test:osx'] +task :test => ['test:ios', 'test:osx'] do + puts "\033[0;31m!! iOS unit tests failed" unless $ios_success + puts "\033[0;31m!! OS X unit tests failed" unless $osx_success + if $ios_success && $osx_success + puts "\033[0;32m** All tests executed successfully" + else + exit(-1) + end +end task :default => 'test' From 2c01759bda16e4016c957bcf9cc0c174944dd4ff Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Mon, 13 May 2013 09:41:44 -0400 Subject: [PATCH 0196/1434] Adjust delays on cancellation test -- unsure why this does not pass when run in the full suite --- Tests/AFHTTPRequestOperationTests.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/AFHTTPRequestOperationTests.m b/Tests/AFHTTPRequestOperationTests.m index 029ce9c818..1350e31cdb 100644 --- a/Tests/AFHTTPRequestOperationTests.m +++ b/Tests/AFHTTPRequestOperationTests.m @@ -53,7 +53,7 @@ - (void)testThatCancellationOfRequestOperationSetsError - (void)testThatCancellationOfRequestOperationInvokesFailureCompletionBlock { __block NSError *blockError = nil; - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/delay/5" relativeToURL:AFNetworkingTestsBaseURL()]]; + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/delay/1" relativeToURL:AFNetworkingTestsBaseURL()]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:nil failure:^(AFHTTPRequestOperation *operation, NSError *error) { blockError = error; @@ -61,8 +61,9 @@ - (void)testThatCancellationOfRequestOperationInvokesFailureCompletionBlock [operation start]; expect([operation isExecuting]).will.beTruthy(); [operation cancel]; + expect(operation.error).willNot.beNil(); expect(blockError).willNot.beNil(); - expect(blockError.code).to.equal(NSURLErrorCancelled); + expect(blockError.code).will.equal(NSURLErrorCancelled); } - (void)testThat500StatusCodeInvokesFailureCompletionBlockWithErrorOnFailure From 30adc3687908dc358c77fdc9ae767cb884bf1e6e Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Mon, 13 May 2013 15:39:44 -0400 Subject: [PATCH 0197/1434] Fix incorrect rake execution in Travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 88802781c3..e87dc1fdb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,4 @@ language: objective-c before_install: - brew update - brew install xctool --HEAD -script: "rake test:all" +script: rake test From deb0776470907e5a065a89f889acea481b7714ed Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 16 May 2013 09:18:00 -0700 Subject: [PATCH 0198/1434] Refactoring test cases to put common initialization in -setUp --- Tests/AFHTTPClientTests.m | 53 +++++------ Tests/AFHTTPRequestOperationTests.m | 89 +++++++++++-------- .../project.pbxproj | 4 +- Tests/AFNetworkingTests.h | 3 +- Tests/AFNetworkingTests.m | 7 +- 5 files changed, 83 insertions(+), 73 deletions(-) diff --git a/Tests/AFHTTPClientTests.m b/Tests/AFHTTPClientTests.m index e7681ed94a..b6f0fd295a 100644 --- a/Tests/AFHTTPClientTests.m +++ b/Tests/AFHTTPClientTests.m @@ -9,58 +9,59 @@ #import "AFNetworkingTests.h" @interface AFHTTPClientTests : SenTestCase +@property (readwrite, nonatomic, strong) AFHTTPClient *client; @end @implementation AFHTTPClientTests +@synthesize client = _client; -- (void)testThatTheDefaultStringEncodingIsUTF8 -{ - AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; - expect(client.stringEncoding).to.equal(NSUTF8StringEncoding); +- (void)setUp { + self.client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; } -- (void)testConstructingPOSTRequestWithParametersInFormURLParameterEncoding -{ - AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; - client.parameterEncoding = AFFormURLParameterEncoding; - NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"/post" parameters:@{ @"key": @"value" }]; +#pragma mark - + +- (void)testThatTheDefaultStringEncodingIsUTF8 { + expect(self.client.stringEncoding).to.equal(NSUTF8StringEncoding); +} + +- (void)testConstructingPOSTRequestWithParametersInFormURLParameterEncoding { + self.client.parameterEncoding = AFFormURLParameterEncoding; + + NSMutableURLRequest *request = [self.client requestWithMethod:@"POST" path:@"/post" parameters:@{ @"key": @"value" }]; NSString *requestBody = [[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding]; expect(requestBody).to.equal(@"key=value"); } -- (void)testConstructingPOSTRequestWithParametersInJSONParameterEncoding -{ - AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; - client.parameterEncoding = AFJSONParameterEncoding; - NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"/post" parameters:@{ @"key": @"value" }]; +- (void)testConstructingPOSTRequestWithParametersInJSONParameterEncoding { + self.client.parameterEncoding = AFJSONParameterEncoding; + + NSMutableURLRequest *request = [self.client requestWithMethod:@"POST" path:@"/post" parameters:@{ @"key": @"value" }]; NSString *requestBody = [[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding]; expect(requestBody).to.equal(@"{\"key\":\"value\"}"); } -- (void)testConstructingPOSTRequestWithParametersInPropertyListParameterEncoding -{ - AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; - client.parameterEncoding = AFPropertyListParameterEncoding; - NSMutableURLRequest *request = [client requestWithMethod:@"POST" path:@"/post" parameters:@{ @"key": @"value" }]; +- (void)testConstructingPOSTRequestWithParametersInPropertyListParameterEncoding { + self.client.parameterEncoding = AFPropertyListParameterEncoding; + + NSMutableURLRequest *request = [self.client requestWithMethod:@"POST" path:@"/post" parameters:@{ @"key": @"value" }]; NSString *requestBody = [[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding]; expect(requestBody).to.equal(@"\n\n\n\n key\n value\n\n\n"); } -- (void)testPostWithParameters -{ +- (void)testPostWithParameters { __block id blockResponseObject = nil; - AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:AFNetworkingTestsBaseURLString]]; - [client postPath:@"/post" parameters:@{ @"key": @"value" } success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.client postPath:@"/post" parameters:@{ @"key": @"value" } success:^(AFHTTPRequestOperation *operation, id responseObject) { blockResponseObject = responseObject; } failure:nil]; - expect([client.operationQueue operationCount]).will.equal(0); + + expect([self.client.operationQueue operationCount]).will.equal(0); expect(blockResponseObject).notTo.beNil(); expect(blockResponseObject).to.beKindOf([NSData class]); + NSError *error = nil; NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:blockResponseObject options:0 error:&error]; expect(responseDictionary[@"form"]).to.equal(@{ @"key": @"value" }); } -// default value for header - @end diff --git a/Tests/AFHTTPRequestOperationTests.m b/Tests/AFHTTPRequestOperationTests.m index 1350e31cdb..f6545f4aeb 100644 --- a/Tests/AFHTTPRequestOperationTests.m +++ b/Tests/AFHTTPRequestOperationTests.m @@ -9,109 +9,124 @@ #import "AFNetworkingTests.h" @interface AFHTTPRequestOperationTests : SenTestCase +@property (readwrite, nonatomic, strong) NSURL *baseURL; @end @implementation AFHTTPRequestOperationTests +@synthesize baseURL = _baseURL; -- (void)testThatOperationInvokesSuccessCompletionBlockWithResponseObjectOnSuccess -{ +- (void)setUp { + self.baseURL = [NSURL URLWithString:AFNetworkingTestsBaseURLString]; +} + +#pragma mark - + +- (void)testThatOperationInvokesSuccessCompletionBlockWithResponseObjectOnSuccess { __block id blockResponseObject = nil; - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/get" relativeToURL:AFNetworkingTestsBaseURL()]]; + + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/get" relativeToURL:self.baseURL]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { blockResponseObject = responseObject; } failure:nil]; + [operation start]; expect([operation isFinished]).will.beTruthy(); expect(blockResponseObject).willNot.beNil(); } -- (void)testThatOperationInvokesFailureCompletionBlockWithErrorOnFailure -{ +- (void)testThatOperationInvokesFailureCompletionBlockWithErrorOnFailure { __block NSError *blockError = nil; - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/status/404" relativeToURL:AFNetworkingTestsBaseURL()]]; + + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/status/404" relativeToURL:self.baseURL]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:nil failure:^(AFHTTPRequestOperation *operation, NSError *error) { blockError = error; }]; + [operation start]; expect([operation isFinished]).will.beTruthy(); expect(blockError).willNot.beNil(); } -- (void)testThatCancellationOfRequestOperationSetsError -{ - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/delay/5" relativeToURL:AFNetworkingTestsBaseURL()]]; +- (void)testThatCancellationOfRequestOperationSetsError { + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/delay/5" relativeToURL:self.baseURL]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + [operation start]; expect([operation isExecuting]).will.beTruthy(); + [operation cancel]; expect(operation.error).willNot.beNil(); expect(operation.error.code).to.equal(NSURLErrorCancelled); } -- (void)testThatCancellationOfRequestOperationInvokesFailureCompletionBlock -{ +- (void)testThatCancellationOfRequestOperationInvokesFailureCompletionBlock { __block NSError *blockError = nil; - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/delay/1" relativeToURL:AFNetworkingTestsBaseURL()]]; + + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/delay/5" relativeToURL:self.baseURL]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:nil failure:^(AFHTTPRequestOperation *operation, NSError *error) { blockError = error; }]; + [operation start]; expect([operation isExecuting]).will.beTruthy(); + [operation cancel]; expect(operation.error).willNot.beNil(); expect(blockError).willNot.beNil(); expect(blockError.code).will.equal(NSURLErrorCancelled); } -- (void)testThat500StatusCodeInvokesFailureCompletionBlockWithErrorOnFailure -{ +- (void)testThat500StatusCodeInvokesFailureCompletionBlockWithErrorOnFailure { __block NSError *blockError = nil; - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/status/500" relativeToURL:AFNetworkingTestsBaseURL()]]; + + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/status/500" relativeToURL:self.baseURL]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:nil failure:^(AFHTTPRequestOperation *operation, NSError *error) { blockError = error; }]; + [operation start]; expect([operation isFinished]).will.beTruthy(); expect(blockError).willNot.beNil(); } -- (void)testThatRedirectBlockIsCalledWhen302IsEncountered -{ +- (void)testThatRedirectBlockIsCalledWhen302IsEncountered { __block BOOL success; - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/redirect/1" relativeToURL:AFNetworkingTestsBaseURL()]]; + + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/redirect/1" relativeToURL:self.baseURL]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:nil failure:nil]; - [operation - setRedirectResponseBlock:^NSURLRequest *(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse) { - if(redirectResponse){ - success = YES; - } - return request; - }]; + [operation setRedirectResponseBlock:^NSURLRequest *(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse) { + if(redirectResponse){ + success = YES; + } + + return request; + }]; + [operation start]; expect([operation isFinished]).will.beTruthy(); expect(success).will.beTruthy(); } -- (void)testThatRedirectBlockIsCalledMultipleTimesWhen302IsEncountered -{ +- (void)testThatRedirectBlockIsCalledMultipleTimesWhen302IsEncountered { __block NSInteger numberOfRedirects = 0; - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/redirect/5" relativeToURL:AFNetworkingTestsBaseURL()]]; + + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/redirect/5" relativeToURL:self.baseURL]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - [operation setCompletionBlockWithSuccess:nil - failure:nil]; - [operation - setRedirectResponseBlock:^NSURLRequest *(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse) { - if(redirectResponse){ - numberOfRedirects++; - } - return request; - }]; + [operation setCompletionBlockWithSuccess:nil failure:nil]; + [operation setRedirectResponseBlock:^NSURLRequest *(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse) { + if(redirectResponse){ + numberOfRedirects++; + } + + return request; + }]; + [operation start]; expect([operation isFinished]).will.beTruthy(); expect(numberOfRedirects).will.equal(5); diff --git a/Tests/AFNetworking Tests.xcodeproj/project.pbxproj b/Tests/AFNetworking Tests.xcodeproj/project.pbxproj index a16b6cc94e..bbbd1a5fb7 100644 --- a/Tests/AFNetworking Tests.xcodeproj/project.pbxproj +++ b/Tests/AFNetworking Tests.xcodeproj/project.pbxproj @@ -199,10 +199,10 @@ 25801548173EB3B00026AA6E /* Tests */ = { isa = PBXGroup; children = ( - 2580153A173EB3A70026AA6E /* AFHTTPClientTests.m */, - 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTests.m */, 2580153E173EB3A70026AA6E /* AFNetworkingTests.h */, 2580153F173EB3A70026AA6E /* AFNetworkingTests.m */, + 2580153B173EB3A70026AA6E /* AFHTTPRequestOperationTests.m */, + 2580153A173EB3A70026AA6E /* AFHTTPClientTests.m */, ); name = Tests; sourceTree = ""; diff --git a/Tests/AFNetworkingTests.h b/Tests/AFNetworkingTests.h index 05c11d335b..86c2c1a4bb 100644 --- a/Tests/AFNetworkingTests.h +++ b/Tests/AFNetworkingTests.h @@ -13,5 +13,4 @@ #import "Expecta.h" #import "OCMock.h" -extern NSString *AFNetworkingTestsBaseURLString; -NSURL *AFNetworkingTestsBaseURL(void); +extern NSString * const AFNetworkingTestsBaseURLString; diff --git a/Tests/AFNetworkingTests.m b/Tests/AFNetworkingTests.m index df81adbba4..2b9ffd4bb3 100644 --- a/Tests/AFNetworkingTests.m +++ b/Tests/AFNetworkingTests.m @@ -6,9 +6,4 @@ // Copyright (c) 2013 AFNetworking. All rights reserved. // -NSString *AFNetworkingTestsBaseURLString = @"http://httpbin.org/"; - -NSURL *AFNetworkingTestsBaseURL(void) -{ - return [NSURL URLWithString:AFNetworkingTestsBaseURLString]; -} +NSString * const AFNetworkingTestsBaseURLString = @"http://httpbin.org/"; From 89ac8bfa67bb10b623660cc4f22f9b7993434625 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 16 May 2013 09:22:36 -0700 Subject: [PATCH 0199/1434] Changing file headers --- Tests/AFHTTPClientTests.m | 22 ++++++++++++++++++---- Tests/AFHTTPRequestOperationTests.m | 22 ++++++++++++++++++---- Tests/AFNetworkingTests.h | 22 ++++++++++++++++++---- Tests/AFNetworkingTests.m | 22 ++++++++++++++++++---- 4 files changed, 72 insertions(+), 16 deletions(-) diff --git a/Tests/AFHTTPClientTests.m b/Tests/AFHTTPClientTests.m index b6f0fd295a..f5728144cb 100644 --- a/Tests/AFHTTPClientTests.m +++ b/Tests/AFHTTPClientTests.m @@ -1,10 +1,24 @@ +// AFHTTPClientTests.m // -// AFHTTPClientTests.m -// AFNetworking +// Copyright (c) 2013 AFNetworking (http://afnetworking.com) // -// Created by Blake Watters on 5/10/13. -// Copyright (c) 2013 AFNetworking. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import "AFNetworkingTests.h" diff --git a/Tests/AFHTTPRequestOperationTests.m b/Tests/AFHTTPRequestOperationTests.m index f6545f4aeb..a9f751ab36 100644 --- a/Tests/AFHTTPRequestOperationTests.m +++ b/Tests/AFHTTPRequestOperationTests.m @@ -1,10 +1,24 @@ +// AFHTTPRequestOperationTests.m // -// AFHTTPRequestOperationTests.m -// AFNetworking +// Copyright (c) 2013 AFNetworking (http://afnetworking.com) // -// Created by Blake Watters on 5/10/13. -// Copyright (c) 2013 AFNetworking. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import "AFNetworkingTests.h" diff --git a/Tests/AFNetworkingTests.h b/Tests/AFNetworkingTests.h index 86c2c1a4bb..a5a5ea2d05 100644 --- a/Tests/AFNetworkingTests.h +++ b/Tests/AFNetworkingTests.h @@ -1,10 +1,24 @@ +// AFNetworkingTests.h // -// AFNetworkingTests.h -// AFNetworking +// Copyright (c) 2013 AFNetworking (http://afnetworking.com) // -// Created by Blake Watters on 5/10/13. -// Copyright (c) 2013 AFNetworking. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import #import "AFNetworking.h" diff --git a/Tests/AFNetworkingTests.m b/Tests/AFNetworkingTests.m index 2b9ffd4bb3..4d51f3935f 100644 --- a/Tests/AFNetworkingTests.m +++ b/Tests/AFNetworkingTests.m @@ -1,9 +1,23 @@ +// AFNetworkingTests.m // -// AFNetworkingTests.m -// AFNetworking +// Copyright (c) 2013 AFNetworking (http://afnetworking.com) // -// Created by Blake Watters on 5/10/13. -// Copyright (c) 2013 AFNetworking. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. NSString * const AFNetworkingTestsBaseURLString = @"http://httpbin.org/"; From 76950dab03049ec6da4f56d42866b9593079ecfd Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 16 May 2013 09:29:11 -0700 Subject: [PATCH 0200/1434] Update README.md --- README.md | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index de2f414d07..04f397f81e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of [NSURLConnection](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html), [NSOperation](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperation_class/Reference/Reference.html), and other familiar Foundation technologies. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. For example, here's how easy it is to get JSON from a URL: -``` objective-c +```objective-c NSURL *url = [NSURL URLWithString:@"https://alpha-api.app.net/stream/0/posts/stream/global"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { @@ -15,7 +15,7 @@ AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperation [operation start]; ``` -Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac. +Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac. Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did! @@ -66,7 +66,7 @@ AFNetworking is architected to be as small and modular as possible, in order to
AFHTTPClient Captures the common patterns of communicating with an web application over HTTP, including: - +