From eb20980e86f06a9e47d33ed7e9cf2979a0bd0f0c Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Wed, 18 Jan 2012 15:53:53 -0800 Subject: [PATCH] Removing exception caused by multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock: is called with certain HTTP methods. Although message bodies for methods like HEAD, GET, and DELETE are traditionally ignored, there is nothing in the HTTP or multipart specs that explicitly forbid the use of multipart for a particular HTTP method. --- AFNetworking/AFHTTPClient.m | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 42a391d..91a4d1b 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -235,7 +235,7 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) { [request setAllHTTPHeaderFields:self.defaultHeaders]; if (parameters) { - if ([method isEqualToString:@"GET"]) { + if ([method isEqualToString:@"GET"] || [method isEqualToString:@"HEAD"] || [method isEqualToString:@"DELETE"]) { url = [NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:[path rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding)]]; [request setURL:url]; } else { @@ -265,11 +265,6 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) { parameters:(NSDictionary *)parameters constructingBodyWithBlock:(void (^)(id formData))block { - if (!([method isEqualToString:@"POST"] || [method isEqualToString:@"PUT"] || [method isEqualToString:@"DELETE"])) { - [NSException raise:@"Invalid HTTP Method" format:@"%@ is not supported for multipart form requests; must be either POST, PUT, or DELETE", method]; - return nil; - } - NSMutableURLRequest *request = [self requestWithMethod:method path:path parameters:nil]; __block AFMultipartFormData *formData = [[AFMultipartFormData alloc] initWithStringEncoding:self.stringEncoding];