diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 62a64bf..41354fb 100755 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -254,15 +254,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 - @param method The HTTP method for the request. Must be either `POST`, `PUT`, or `DELETE`. + @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. - - @warning An exception will be raised if the specified method is not `POST`, `PUT` or `DELETE`. - + @return An `NSMutableURLRequest` object */ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index bf6da78..346bb76 100755 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -465,6 +465,9 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {} parameters:(NSDictionary *)parameters constructingBodyWithBlock:(void (^)(id formData))block { + NSCParameterAssert(method); + NSCParameterAssert(![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];