From 30aeb09d2f22a96c613567ae61f62203ac53fd56 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Tue, 9 Oct 2012 08:58:13 -0700 Subject: [PATCH] Adding requirement that method not be nil in requestWithMethod:path:parameters Defaulting path to blank string if nil --- AFNetworking/AFHTTPClient.h | 6 +++--- AFNetworking/AFHTTPClient.m | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 869282e..62a64bf 100755 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -239,10 +239,10 @@ typedef enum { /** Creates an `NSMutableURLRequest` object with the specified HTTP method and path. - If the HTTP method is `GET`, 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. + 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`. - @param path The path to be appended to the HTTP client's base URL and used as the request URL. + @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 diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 81745ce..bf6da78 100755 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -423,6 +423,12 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {} path:(NSString *)path parameters:(NSDictionary *)parameters { + NSCParameterAssert(method); + + if (!path) { + path = @""; + } + NSURL *url = [NSURL URLWithString:path relativeToURL:self.baseURL]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; [request setHTTPMethod:method];