Re-indenting AFHTTPClient.m

This commit is contained in:
Mattt Thompson 2012-09-03 11:11:24 -07:00
parent 70dff01807
commit 858c716c16

View file

@ -1,17 +1,17 @@
// AFHTTPClient.m // AFHTTPClient.m
// //
// Copyright (c) 2011 Gowalla (http://gowalla.com/) // Copyright (c) 2011 Gowalla (http://gowalla.com/)
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights // in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is // copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: // furnished to do so, subject to the following conditions:
// //
// The above copyright notice and this permission notice shall be included in // The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software. // all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -43,7 +43,7 @@
@interface AFMultipartFormData : NSObject <AFMultipartFormData> @interface AFMultipartFormData : NSObject <AFMultipartFormData>
- (id)initWithURLRequest:(NSMutableURLRequest *)request - (id)initWithURLRequest:(NSMutableURLRequest *)request
stringEncoding:(NSStringEncoding)encoding; stringEncoding:(NSStringEncoding)encoding;
- (NSMutableURLRequest *)requestByFinalizingMultipartFormData; - (NSMutableURLRequest *)requestByFinalizingMultipartFormData;
@ -77,7 +77,7 @@ static NSString * AFBase64EncodedStringFromString(NSString *string) {
for (NSUInteger j = i; j < (i + 3); j++) { for (NSUInteger j = i; j < (i + 3); j++) {
value <<= 8; value <<= 8;
if (j < length) { if (j < length) {
value |= (0xFF & input[j]); value |= (0xFF & input[j]);
} }
} }
@ -96,7 +96,7 @@ static NSString * AFBase64EncodedStringFromString(NSString *string) {
NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding) {
// Escape characters that are legal in URIs, but have unintentional semantic significance when used in a query string parameter // Escape characters that are legal in URIs, but have unintentional semantic significance when used in a query string parameter
static NSString * const kAFLegalCharactersToBeEscaped = @":/.?&=;+!@$()~"; static NSString * const kAFLegalCharactersToBeEscaped = @":/.?&=;+!@$()~";
return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, (CFStringRef)kAFLegalCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)) autorelease]; return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, (CFStringRef)kAFLegalCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)) autorelease];
} }
@ -111,7 +111,7 @@ NSString * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString
@end @end
@implementation AFQueryStringPair @implementation AFQueryStringPair
@synthesize field = _field; @synthesize field = _field;
@synthesize value = _value; @synthesize value = _value;
@ -170,7 +170,7 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) {
}]; }];
} else { } else {
[mutableQueryStringComponents addObject:[[[AFQueryStringPair alloc] initWithField:key value:value] autorelease]]; [mutableQueryStringComponents addObject:[[[AFQueryStringPair alloc] initWithField:key value:value] autorelease]];
} }
return mutableQueryStringComponents; return mutableQueryStringComponents;
} }
@ -250,22 +250,22 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
self.registeredHTTPOperationClassNames = [NSMutableArray array]; self.registeredHTTPOperationClassNames = [NSMutableArray array];
self.defaultHeaders = [NSMutableDictionary dictionary]; self.defaultHeaders = [NSMutableDictionary dictionary];
// Accept-Encoding HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 // Accept-Encoding HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
[self setDefaultHeader:@"Accept-Encoding" value:@"gzip"]; [self setDefaultHeader:@"Accept-Encoding" value:@"gzip"];
// Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
NSString *preferredLanguageCodes = [[NSLocale preferredLanguages] componentsJoinedByString:@", "]; NSString *preferredLanguageCodes = [[NSLocale preferredLanguages] componentsJoinedByString:@", "];
[self setDefaultHeader:@"Accept-Language" value:[NSString stringWithFormat:@"%@, en-us;q=0.8", preferredLanguageCodes]]; [self setDefaultHeader:@"Accept-Language" value:[NSString stringWithFormat:@"%@, en-us;q=0.8", preferredLanguageCodes]];
#if __IPHONE_OS_VERSION_MIN_REQUIRED #if __IPHONE_OS_VERSION_MIN_REQUIRED
// User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 // 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], 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)]]; [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], 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 __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]]]; [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 #endif
#ifdef _SYSTEMCONFIGURATION_H #ifdef _SYSTEMCONFIGURATION_H
self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown;
[self startMonitoringNetworkReachability]; [self startMonitoringNetworkReachability];
@ -326,7 +326,7 @@ static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetwork
return status; return status;
} }
static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
AFNetworkReachabilityStatusBlock block = (AFNetworkReachabilityStatusBlock)info; AFNetworkReachabilityStatusBlock block = (AFNetworkReachabilityStatusBlock)info;
if (block) { if (block) {
@ -432,20 +432,20 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
#pragma mark - #pragma mark -
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method - (NSMutableURLRequest *)requestWithMethod:(NSString *)method
path:(NSString *)path path:(NSString *)path
parameters:(NSDictionary *)parameters parameters:(NSDictionary *)parameters
{ {
NSURL *url = [NSURL URLWithString:path relativeToURL:self.baseURL]; NSURL *url = [NSURL URLWithString:path relativeToURL:self.baseURL];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease];
[request setHTTPMethod:method]; [request setHTTPMethod:method];
[request setAllHTTPHeaderFields:self.defaultHeaders]; [request setAllHTTPHeaderFields:self.defaultHeaders];
if ([method isEqualToString:@"GET"] || [method isEqualToString:@"HEAD"]) { if ([method isEqualToString:@"GET"] || [method isEqualToString:@"HEAD"]) {
[request setHTTPShouldUsePipelining:YES]; [request setHTTPShouldUsePipelining:YES];
} }
if (parameters) { if (parameters) {
if ([method isEqualToString:@"GET"] || [method isEqualToString:@"HEAD"] || [method isEqualToString:@"DELETE"]) { if ([method isEqualToString:@"GET"] || [method isEqualToString:@"HEAD"] || [method isEqualToString:@"DELETE"]) {
url = [NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:[path rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding)]]; url = [NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:[path rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding)]];
[request setURL:url]; [request setURL:url];
@ -501,7 +501,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
return [formData requestByFinalizingMultipartFormData]; return [formData requestByFinalizingMultipartFormData];
} }
- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{ {
@ -542,8 +542,8 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
} }
} }
- (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)requests - (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)requests
progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
completionBlock:(void (^)(NSArray *operations))completionBlock completionBlock:(void (^)(NSArray *operations))completionBlock
{ {
NSMutableArray *mutableOperations = [NSMutableArray array]; NSMutableArray *mutableOperations = [NSMutableArray array];
@ -555,8 +555,8 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
[self enqueueBatchOfHTTPRequestOperations:mutableOperations progressBlock:progressBlock completionBlock:completionBlock]; [self enqueueBatchOfHTTPRequestOperations:mutableOperations progressBlock:progressBlock completionBlock:completionBlock];
} }
- (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations
progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
completionBlock:(void (^)(NSArray *operations))completionBlock completionBlock:(void (^)(NSArray *operations))completionBlock
{ {
__block dispatch_group_t dispatchGroup = dispatch_group_create(); __block dispatch_group_t dispatchGroup = dispatch_group_create();
@ -568,7 +568,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
}); });
dispatch_release(dispatchGroup); dispatch_release(dispatchGroup);
}]; }];
for (AFHTTPRequestOperation *operation in operations) { for (AFHTTPRequestOperation *operation in operations) {
AFCompletionBlock originalCompletionBlock = [[operation.completionBlock copy] autorelease]; AFCompletionBlock originalCompletionBlock = [[operation.completionBlock copy] autorelease];
operation.completionBlock = ^{ operation.completionBlock = ^{
@ -603,8 +603,8 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
#pragma mark - #pragma mark -
- (void)getPath:(NSString *)path - (void)getPath:(NSString *)path
parameters:(NSDictionary *)parameters parameters:(NSDictionary *)parameters
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{ {
@ -613,8 +613,8 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
[self enqueueHTTPRequestOperation:operation]; [self enqueueHTTPRequestOperation:operation];
} }
- (void)postPath:(NSString *)path - (void)postPath:(NSString *)path
parameters:(NSDictionary *)parameters parameters:(NSDictionary *)parameters
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{ {
@ -623,8 +623,8 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
[self enqueueHTTPRequestOperation:operation]; [self enqueueHTTPRequestOperation:operation];
} }
- (void)putPath:(NSString *)path - (void)putPath:(NSString *)path
parameters:(NSDictionary *)parameters parameters:(NSDictionary *)parameters
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{ {
@ -633,8 +633,8 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
[self enqueueHTTPRequestOperation:operation]; [self enqueueHTTPRequestOperation:operation];
} }
- (void)deletePath:(NSString *)path - (void)deletePath:(NSString *)path
parameters:(NSDictionary *)parameters parameters:(NSDictionary *)parameters
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{ {
@ -643,8 +643,8 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
[self enqueueHTTPRequestOperation:operation]; [self enqueueHTTPRequestOperation:operation];
} }
- (void)patchPath:(NSString *)path - (void)patchPath:(NSString *)path
parameters:(NSDictionary *)parameters parameters:(NSDictionary *)parameters
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{ {
@ -735,7 +735,7 @@ static inline NSString * AFMultipartFormFinalBoundary() {
@property (readwrite, nonatomic, retain) NSMutableURLRequest *request; @property (readwrite, nonatomic, retain) NSMutableURLRequest *request;
@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; @property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding;
@property (readwrite, nonatomic, retain) NSOutputStream *outputStream; @property (readwrite, nonatomic, retain) NSOutputStream *outputStream;
@property (readwrite, nonatomic, copy) NSString *temporaryFilePath; @property (readwrite, nonatomic, copy) NSString *temporaryFilePath;
@end @end
@implementation AFMultipartFormData @implementation AFMultipartFormData
@ -744,8 +744,8 @@ static inline NSString * AFMultipartFormFinalBoundary() {
@synthesize outputStream = _outputStream; @synthesize outputStream = _outputStream;
@synthesize temporaryFilePath = _temporaryFilePath; @synthesize temporaryFilePath = _temporaryFilePath;
- (id)initWithURLRequest:(NSMutableURLRequest *)request - (id)initWithURLRequest:(NSMutableURLRequest *)request
stringEncoding:(NSStringEncoding)encoding stringEncoding:(NSStringEncoding)encoding
{ {
self = [super init]; self = [super init];
if (!self) { if (!self) {
@ -785,7 +785,7 @@ static inline NSString * AFMultipartFormFinalBoundary() {
return self.request; return self.request;
} }
[self appendData:[AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding]]; [self appendData:[AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding]];
[self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", kAFMultipartFormBoundary] forHTTPHeaderField:@"Content-Type"]; [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", kAFMultipartFormBoundary] forHTTPHeaderField:@"Content-Type"];
@ -807,8 +807,8 @@ static inline NSString * AFMultipartFormFinalBoundary() {
} }
} }
- (void)appendPartWithHeaders:(NSDictionary *)headers - (void)appendPartWithHeaders:(NSDictionary *)headers
body:(NSData *)body body:(NSData *)body
{ {
[self appendBoundary]; [self appendBoundary];
@ -820,8 +820,8 @@ static inline NSString * AFMultipartFormFinalBoundary() {
[self appendData:body]; [self appendData:body];
} }
- (void)appendPartWithFormData:(NSData *)data - (void)appendPartWithFormData:(NSData *)data
name:(NSString *)name name:(NSString *)name
{ {
NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
[mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"]; [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"];
@ -829,11 +829,11 @@ static inline NSString * AFMultipartFormFinalBoundary() {
[self appendPartWithHeaders:mutableHeaders body:data]; [self appendPartWithHeaders:mutableHeaders body:data];
} }
- (void)appendPartWithFileData:(NSData *)data - (void)appendPartWithFileData:(NSData *)data
name:(NSString *)name name:(NSString *)name
fileName:(NSString *)fileName fileName:(NSString *)fileName
mimeType:(NSString *)mimeType mimeType:(NSString *)mimeType
{ {
NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
[mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
[mutableHeaders setValue:mimeType forKey:@"Content-Type"]; [mutableHeaders setValue:mimeType forKey:@"Content-Type"];
@ -841,9 +841,9 @@ static inline NSString * AFMultipartFormFinalBoundary() {
[self appendPartWithHeaders:mutableHeaders body:data]; [self appendPartWithHeaders:mutableHeaders body:data];
} }
- (BOOL)appendPartWithFileURL:(NSURL *)fileURL - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
name:(NSString *)name name:(NSString *)name
error:(NSError **)error error:(NSError **)error
{ {
if (![fileURL isFileURL]) { if (![fileURL isFileURL]) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
@ -879,7 +879,7 @@ static inline NSString * AFMultipartFormFinalBoundary() {
if ([data length] == 0) { if ([data length] == 0) {
return; return;
} }
if ([self.outputStream hasSpaceAvailable]) { if ([self.outputStream hasSpaceAvailable]) {
const uint8_t *dataBuffer = (uint8_t *) [data bytes]; const uint8_t *dataBuffer = (uint8_t *) [data bytes];
[self.outputStream write:&dataBuffer[0] maxLength:[data length]]; [self.outputStream write:&dataBuffer[0] maxLength:[data length]];