Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 395 lines (297 sloc) 20.48 kb
ebb6eb2 @mattt You know what's an even _better name? AFHTTPClient. Boom.
mattt authored
1 // AFHTTPClient.h
5b27bf6 @mattt Extracting core aspects of AFGowallaAPI into AFRestClient
mattt authored
2 //
3 // Copyright (c) 2011 Gowalla (http://gowalla.com/)
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22
23 #import <Foundation/Foundation.h>
24
b28b99d @mattt Moving AFHTTPClientOperation protocol to AFHTTPClient
mattt authored
25 @class AFHTTPRequestOperation;
26 @protocol AFHTTPClientOperation;
945e196 @mattt Renaming AFMultipartFormDataProxy to AFMultipartFormData, in order to…
mattt authored
27 @protocol AFMultipartFormData;
8833578 @mattt Adding NSMutableURLRequest category with -setHTTPBodyWithData:mimeTyp…
mattt authored
28
49d5c65 @mattt Documentation for AFHTTPClient and AFHTTPClientOperation protocol
mattt authored
29 /**
30 Method used to encode parameters into request body
31 */
6f20f84 @mattt Adding AFHTTPClientParameterEncoding @property to AFHTTPClient, which…
mattt authored
32 typedef enum {
33 AFFormURLParameterEncoding,
34 AFJSONParameterEncoding,
35 AFPropertyListParameterEncoding,
36 } AFHTTPClientParameterEncoding;
37
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
38 /**
49d5c65 @mattt Documentation for AFHTTPClient and AFHTTPClientOperation protocol
mattt authored
39 `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.
40
41 ## Automatic Content Parsing
42
43 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. See `AFHTTPClientOperation` for further details.
44
45 ## Subclassing Notes
46
47 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.
48
49 ## Methods to Override
424f6de @mattt Adding documentation to AFHTTPClient
mattt authored
50
49d5c65 @mattt Documentation for AFHTTPClient and AFHTTPClientOperation protocol
mattt authored
51 To change the behavior of all url request construction for an `AFHTTPClient` subclass, override `requestWithMethod:path:parameters`.
52
53 ## Default Headers
54
55 By default, `AFHTTPClient` sets the following HTTP headers:
424f6de @mattt Adding documentation to AFHTTPClient
mattt authored
56
57 - `Accept: application/json`
58 - `Accept-Encoding: gzip`
59 - `Accept-Language: #{[NSLocale preferredLanguages]}, en-us;q=0.8`
97d4d17 @mattt Adding missing backtick for class documentation
mattt authored
60 - `User-Agent: #{generated user agent}`
424f6de @mattt Adding documentation to AFHTTPClient
mattt authored
61
62 You can override these HTTP headers or define new ones using `setDefaultHeader:value:`.
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
63 */
ebb6eb2 @mattt You know what's an even _better name? AFHTTPClient. Boom.
mattt authored
64 @interface AFHTTPClient : NSObject {
2b9a66d @mattt Changing AFRestClient +baseURL to a @property
mattt authored
65 @private
66 NSURL *_baseURL;
ca02e02 @mattt Removing categories on NSData and NSString, moving them to static fun…
mattt authored
67 NSStringEncoding _stringEncoding;
6f20f84 @mattt Adding AFHTTPClientParameterEncoding @property to AFHTTPClient, which…
mattt authored
68 AFHTTPClientParameterEncoding _parameterEncoding;
c2be31d @mattt First implementation of protocol for AFHTTPClient to register classes…
mattt authored
69 NSMutableArray *_registeredHTTPOperationClassNames;
d87b783 @mattt Porting over changes for 0.3.0 release
mattt authored
70 NSMutableDictionary *_defaultHeaders;
71 NSOperationQueue *_operationQueue;
72 }
73
424f6de @mattt Adding documentation to AFHTTPClient
mattt authored
74 ///---------------------------------------
75 /// @name Accessing HTTP Client Properties
76 ///---------------------------------------
77
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
78 /**
4f070b2 @teeman file data upload fix
teeman authored
79 The url used as the base for paths specified in methods such as `getPath:parameteres:success:failure`
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
80 */
81 @property (readonly, nonatomic, retain) NSURL *baseURL;
82
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
83 /**
84 The string encoding used in constructing url requests. This is `NSUTF8StringEncoding` by default.
85 */
ca02e02 @mattt Removing categories on NSData and NSString, moving them to static fun…
mattt authored
86 @property (nonatomic, assign) NSStringEncoding stringEncoding;
87
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
88 /**
6f20f84 @mattt Adding AFHTTPClientParameterEncoding @property to AFHTTPClient, which…
mattt authored
89
90 */
91 @property (nonatomic, assign) AFHTTPClientParameterEncoding parameterEncoding;
92
93 /**
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
94 The operation queue which manages operations enqueued by the HTTP client.
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
95 */
f4f295f @mattt Removing extra semicolons
mattt authored
96 @property (readonly, nonatomic, retain) NSOperationQueue *operationQueue;
ca02e02 @mattt Removing categories on NSData and NSString, moving them to static fun…
mattt authored
97
2dd6821 @mattt Adding +clientWithBaseURL:
mattt authored
98 ///---------------------------------------------
99 /// @name Creating and Initializing HTTP Clients
100 ///---------------------------------------------
101
102 /**
103 Creates and initializes an `AFHTTPClient` object with the specified base URL.
104
105 @param url The base URL for the HTTP client. This argument must not be nil.
106
107 @return The newly-initialized HTTP client
108 */
109 + (AFHTTPClient *)clientWithBaseURL:(NSURL *)url;
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
110
111 /**
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
112 Initializes an `AFHTTPClient` object with the specified base URL.
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
113
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
114 @param url The base URL for the HTTP client. This argument must not be nil.
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
115
2dd6821 @mattt Adding +clientWithBaseURL:
mattt authored
116 @discussion This is the designated initializer for `AFHTTPClient`
117
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
118 @return The newly-initialized HTTP client
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
119 */
2b9a66d @mattt Changing AFRestClient +baseURL to a @property
mattt authored
120 - (id)initWithBaseURL:(NSURL *)url;
121
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
122 ///----------------------------------
c2be31d @mattt First implementation of protocol for AFHTTPClient to register classes…
mattt authored
123 /// @name Managing HTTP Operations
124 ///----------------------------------
125
126 - (BOOL)registerHTTPOperationClass:(Class)operationClass;
127
128 ///----------------------------------
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
129 /// @name Managing HTTP Header Values
130 ///----------------------------------
131
132 /**
424f6de @mattt Adding documentation to AFHTTPClient
mattt authored
133 Returns the value for the HTTP headers set in request objects created by the HTTP client.
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
134
135 @param header The HTTP header to return the default value for
136
137 @return The default value for the HTTP header, or `nil` if unspecified
138 */
5b27bf6 @mattt Extracting core aspects of AFGowallaAPI into AFRestClient
mattt authored
139 - (NSString *)defaultValueForHeader:(NSString *)header;
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
140
141 /**
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
142 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.
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
143
144 @param header The HTTP header to set a default value for
145 @param value The value set as default for the specified header, or `nil
146 */
5b27bf6 @mattt Extracting core aspects of AFGowallaAPI into AFRestClient
mattt authored
147 - (void)setDefaultHeader:(NSString *)header value:(NSString *)value;
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
148
149 /**
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
150 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.
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
151
152 @param username The HTTP basic auth username
153 @param password The HTTP basic auth password
154 */
f8d3550 @mattt Experimental implementation of HTTP Basic auth helper in AFRestClient
mattt authored
155 - (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password;
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
156
157 /**
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
158 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.
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
159
160 @param token The authentication token
161 */
5b27bf6 @mattt Extracting core aspects of AFGowallaAPI into AFRestClient
mattt authored
162 - (void)setAuthorizationHeaderWithToken:(NSString *)token;
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
163
164 /**
165 Clears any existing value for the "Authorization" HTTP header.
166 */
5b27bf6 @mattt Extracting core aspects of AFGowallaAPI into AFRestClient
mattt authored
167 - (void)clearAuthorizationHeader;
168
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
169 ///-------------------------------
170 /// @name Creating Request Objects
171 ///-------------------------------
172
173 /**
49d5c65 @mattt Documentation for AFHTTPClient and AFHTTPClientOperation protocol
mattt authored
174 Creates an `NSMutableURLRequest` object with the specified HTTP method and path. By default, this method scans through the registered operation classes (in reverse order of when they were specified), until finding one that can handle the specified request.
175
176 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.
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
177
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
178 @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`.
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
179 @param path The path to be appended to the HTTP client's base URL and used as the request URL.
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
180 @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
181
182 @return An `NSMutableURLRequest` object
49d5c65 @mattt Documentation for AFHTTPClient and AFHTTPClientOperation protocol
mattt authored
183
184 @see AFHTTPClientOperation
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
185 */
8833578 @mattt Adding NSMutableURLRequest category with -setHTTPBodyWithData:mimeTyp…
mattt authored
186 - (NSMutableURLRequest *)requestWithMethod:(NSString *)method
424f6de @mattt Adding documentation to AFHTTPClient
mattt authored
187 path:(NSString *)path
188 parameters:(NSDictionary *)parameters;
d87b783 @mattt Porting over changes for 0.3.0 release
mattt authored
189
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
190 /**
945e196 @mattt Renaming AFMultipartFormDataProxy to AFMultipartFormData, in order to…
mattt authored
191 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
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
192
193 @param method The HTTP method for the request. Must be either `POST`, `PUT`, or `DELETE`.
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
194 @param path The path to be appended to the HTTP client's base URL and used as the request URL.
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
195 @param parameters The parameters to be encoded and set in the request HTTP body.
945e196 @mattt Renaming AFMultipartFormDataProxy to AFMultipartFormData, in order to…
mattt authored
196 @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.
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
197
945e196 @mattt Renaming AFMultipartFormDataProxy to AFMultipartFormData, in order to…
mattt authored
198 @see AFMultipartFormData
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
199
49d5c65 @mattt Documentation for AFHTTPClient and AFHTTPClientOperation protocol
mattt authored
200 @warning An exception will be raised if the specified method is not `POST`, `PUT` or `DELETE`.
201
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
202 @return An `NSMutableURLRequest` object
203 */
8b86051 @mattt Replacing NSMutableURLRequest category method with more flexible cons…
mattt authored
204 - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
205 path:(NSString *)path
206 parameters:(NSDictionary *)parameters
945e196 @mattt Renaming AFMultipartFormDataProxy to AFMultipartFormData, in order to…
mattt authored
207 constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block;
8b86051 @mattt Replacing NSMutableURLRequest category method with more flexible cons…
mattt authored
208
209
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
210 ///--------------------------------
211 /// @name Enqueuing HTTP Operations
212 ///--------------------------------
72d9a24 @mattt Adding AFRestClient -enqueueHTTPOperation:
mattt authored
213
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
214 /**
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
215 Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue.
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
216
217 @param request The request object to be loaded asynchronously during execution of the operation.
eda2d1a @mattt Expanding AFJSONRequestOperation and AFHTTPClient failure blocks to i…
mattt authored
218 @param success A block object to be executed when the request operation finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `application/json`). This block has no return value and takes a single argument, which is an object created from the response data of request.
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
219 @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 resonse data as JSON. This block has no return value and takes a single argument, which is the `NSError` object describing the network or parsing error that occurred.
220 */
ccdc5f2 @mattt Approaching a reasonable design for restructuring AFHTTPRequestOperat…
mattt authored
221 - (void)enqueueHTTPRequestOperationWithRequest:(NSURLRequest *)request
222 success:(void (^)(id object))success
223 failure:(void (^)(NSHTTPURLResponse *response, NSError *error))failure;
6f20f84 @mattt Adding AFHTTPClientParameterEncoding @property to AFHTTPClient, which…
mattt authored
224 /**
225 */
226 - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation;
d87b783 @mattt Porting over changes for 0.3.0 release
mattt authored
227
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
228 ///---------------------------------
229 /// @name Cancelling HTTP Operations
230 ///---------------------------------
231
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
232 /**
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
233 Cancels all operations in the HTTP client's operation queue that match the specified HTTP method and URL.
c0c79a7 @mattt Further additions to AFRestClient documentation
mattt authored
234
235 @param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`.
236 @param url The URL to match for the cancelled requests.
237 */
238 - (void)cancelHTTPOperationsWithMethod:(NSString *)method andURL:(NSURL *)url;
4d5ae42 @mattt Adding AFRestClient -cancelHTTPOperationsWithRequest: and -cancelAllH…
mattt authored
239
2f7f527 @mattt First (half of a) draft of AFRestClient documentation
mattt authored
240 ///---------------------------
241 /// @name Making HTTP Requests
242 ///---------------------------
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
243
244 /**
245 Creates an `AFHTTPRequestOperation` with a `GET` request, and enqueues it to the HTTP client's operation queue.
246
247 @param path The path to be appended to the HTTP client's base URL and used as the request URL.
248 @param parameters The parameters to be encoded and appended as the query string for the request URL.
7a2cad0 @mattt Minor revisions to documentation, mostly around style and conventions
mattt authored
249 @param success A block object to be executed when the request operation finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `application/json`). This block has no return value and takes a single argument, which is the response object created from the response data of request.
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
250 @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 resonse data as JSON. This block has no return value and takes a single argument, which is the `NSError` object describing the network or parsing error that occurred.
eda2d1a @mattt Expanding AFJSONRequestOperation and AFHTTPClient failure blocks to i…
mattt authored
251
252 @see enqueueHTTPOperationWithRequest:success:failure
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
253 */
8b86051 @mattt Replacing NSMutableURLRequest category method with more flexible cons…
mattt authored
254 - (void)getPath:(NSString *)path
255 parameters:(NSDictionary *)parameters
eda2d1a @mattt Expanding AFJSONRequestOperation and AFHTTPClient failure blocks to i…
mattt authored
256 success:(void (^)(id object))success
257 failure:(void (^)(NSHTTPURLResponse *response, NSError *error))failure;
5b27bf6 @mattt Extracting core aspects of AFGowallaAPI into AFRestClient
mattt authored
258
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
259 /**
260 Creates an `AFHTTPRequestOperation` with a `POST` request, and enqueues it to the HTTP client's operation queue.
261
262 @param path The path to be appended to the HTTP client's base URL and used as the request URL.
263 @param parameters The parameters to be encoded and set in the request HTTP body.
7a2cad0 @mattt Minor revisions to documentation, mostly around style and conventions
mattt authored
264 @param success A block object to be executed when the request operation finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `application/json`). This block has no return value and takes a single argument, which is the response object created from the response data of request.
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
265 @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 resonse data as JSON. This block has no return value and takes a single argument, which is the `NSError` object describing the network or parsing error that occurred.
eda2d1a @mattt Expanding AFJSONRequestOperation and AFHTTPClient failure blocks to i…
mattt authored
266
267 @see enqueueHTTPOperationWithRequest:success:failure
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
268 */
8833578 @mattt Adding NSMutableURLRequest category with -setHTTPBodyWithData:mimeTyp…
mattt authored
269 - (void)postPath:(NSString *)path
270 parameters:(NSDictionary *)parameters
eda2d1a @mattt Expanding AFJSONRequestOperation and AFHTTPClient failure blocks to i…
mattt authored
271 success:(void (^)(id object))success
272 failure:(void (^)(NSHTTPURLResponse *response, NSError *error))failure;
8833578 @mattt Adding NSMutableURLRequest category with -setHTTPBodyWithData:mimeTyp…
mattt authored
273
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
274 /**
275 Creates an `AFHTTPRequestOperation` with a `PUT` request, and enqueues it to the HTTP client's operation queue.
276
277 @param path The path to be appended to the HTTP client's base URL and used as the request URL.
278 @param parameters The parameters to be encoded and set in the request HTTP body.
7a2cad0 @mattt Minor revisions to documentation, mostly around style and conventions
mattt authored
279 @param success A block object to be executed when the request operation finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `application/json`). This block has no return value and takes a single argument, which is the response object created from the response data of request.
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
280 @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 resonse data as JSON. This block has no return value and takes a single argument, which is the `NSError` object describing the network or parsing error that occurred.
eda2d1a @mattt Expanding AFJSONRequestOperation and AFHTTPClient failure blocks to i…
mattt authored
281
282 @see enqueueHTTPOperationWithRequest:success:failure
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
283 */
8833578 @mattt Adding NSMutableURLRequest category with -setHTTPBodyWithData:mimeTyp…
mattt authored
284 - (void)putPath:(NSString *)path
285 parameters:(NSDictionary *)parameters
eda2d1a @mattt Expanding AFJSONRequestOperation and AFHTTPClient failure blocks to i…
mattt authored
286 success:(void (^)(id object))success
287 failure:(void (^)(NSHTTPURLResponse *response, NSError *error))failure;
5b27bf6 @mattt Extracting core aspects of AFGowallaAPI into AFRestClient
mattt authored
288
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
289 /**
290 Creates an `AFHTTPRequestOperation` with a `DELETE` request, and enqueues it to the HTTP client's operation queue.
291
292 @param path The path to be appended to the HTTP client's base URL and used as the request URL.
293 @param parameters The parameters to be encoded and set in the request HTTP body.
7a2cad0 @mattt Minor revisions to documentation, mostly around style and conventions
mattt authored
294 @param success A block object to be executed when the request operation finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `application/json`). This block has no return value and takes a single argument, which is the response object created from the response data of request.
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
295 @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 resonse data as JSON. This block has no return value and takes a single argument, which is the `NSError` object describing the network or parsing error that occurred.
eda2d1a @mattt Expanding AFJSONRequestOperation and AFHTTPClient failure blocks to i…
mattt authored
296
297 @see enqueueHTTPOperationWithRequest:success:failure
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
298 */
8833578 @mattt Adding NSMutableURLRequest category with -setHTTPBodyWithData:mimeTyp…
mattt authored
299 - (void)deletePath:(NSString *)path
300 parameters:(NSDictionary *)parameters
eda2d1a @mattt Expanding AFJSONRequestOperation and AFHTTPClient failure blocks to i…
mattt authored
301 success:(void (^)(id object))success
302 failure:(void (^)(NSHTTPURLResponse *response, NSError *error))failure;
b28b99d @mattt Moving AFHTTPClientOperation protocol to AFHTTPClient
mattt authored
303 @end
304
305 #pragma mark -
306
49d5c65 @mattt Documentation for AFHTTPClient and AFHTTPClientOperation protocol
mattt authored
307 /**
308 The `AFHTTPClientOperation` protocol defines the methods used for the automatic content parsing functionality of `AFHTTPClient`.
309
310 @see `AFHTTPClient -registerHTTPOperationClass:`
311 */
312 @protocol AFHTTPClientOperation
313
314 /**
315 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`.
316
317 @param urlRequest The request that is determined to be supported or not supported for this class.
318 */
319 + (BOOL)canProcessRequest:(NSURLRequest *)urlRequest;
320
321 /**
322 Constructs and initializes an operation with success and failure callbacks.
323
324 @param urlRequest The request used by the operation connection.
325 @param success A block object to be executed when the operation finishes successfully. The block has no return value and takes a single argument, the response object from the request.
326 @param failure A block object to be executed when the operation finishes unsuccessfully. The block has no return value and takes two arguments: the response received from the server, and the error describing the network or parsing error that occurred.
327 */
b28b99d @mattt Moving AFHTTPClientOperation protocol to AFHTTPClient
mattt authored
328 + (id)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest
329 success:(void (^)(id object))success
330 failure:(void (^)(NSHTTPURLResponse *response, NSError *error))failure;
5b27bf6 @mattt Extracting core aspects of AFGowallaAPI into AFRestClient
mattt authored
331 @end
8b86051 @mattt Replacing NSMutableURLRequest category method with more flexible cons…
mattt authored
332
333 #pragma mark -
334
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
335 /**
945e196 @mattt Renaming AFMultipartFormDataProxy to AFMultipartFormData, in order to…
mattt authored
336 The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:`.
49d5c65 @mattt Documentation for AFHTTPClient and AFHTTPClientOperation protocol
mattt authored
337
338 @see `AFHTTPClient -multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:`
339
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
340 */
945e196 @mattt Renaming AFMultipartFormDataProxy to AFMultipartFormData, in order to…
mattt authored
341 @protocol AFMultipartFormData
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
342
343 /**
344 Appends HTTP headers, followed by the encoded data and the multipart form boundary.
345
346 @param headers The HTTP headers to be appended to the form data.
347 @param body The data to be encoded and appended to the form data.
348 */
8b86051 @mattt Replacing NSMutableURLRequest category method with more flexible cons…
mattt authored
349 - (void)appendPartWithHeaders:(NSDictionary *)headers body:(NSData *)body;
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
350
351 /**
945e196 @mattt Renaming AFMultipartFormDataProxy to AFMultipartFormData, in order to…
mattt authored
352 Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
353
354 @param data The data to be encoded and appended to the form data.
b621ad0 @mattt Changing multipart form data object to be subclass of NSMutableData
mattt authored
355 @param name The name to be associated with the specified data. This parameter must not be `nil`.
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
356 */
945e196 @mattt Renaming AFMultipartFormDataProxy to AFMultipartFormData, in order to…
mattt authored
357 - (void)appendPartWithFormData:(NSData *)data name:(NSString *)name;
358
359 /**
360 Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
361
362 @param data The data to be encoded and appended to the form data.
363 @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`.
364 @param name The name to be associated with the specified data. This parameter must not be `nil`.
365
366 @discussion The filename associated with this data in the form will be automatically generated using the parameter name specified and a unique timestamp-based hash.
367 */
368 - (void)appendPartWithFileData:(NSData *)data mimeType:(NSString *)mimeType name:(NSString *)name;
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
369
370 /**
b621ad0 @mattt Changing multipart form data object to be subclass of NSMutableData
mattt authored
371 Appends the HTTP header `Content-Disposition: file; filename=#{filename}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
372
b621ad0 @mattt Changing multipart form data object to be subclass of NSMutableData
mattt authored
373 @param fileURL The URL for the local file to have its contents appended to the form data. This parameter must not be `nil`.
374 @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`.
375 @param fileName The filename to be associated with the file contents. This parameter must not be `nil`.
945e196 @mattt Renaming AFMultipartFormDataProxy to AFMultipartFormData, in order to…
mattt authored
376 @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
377 */
945e196 @mattt Renaming AFMultipartFormDataProxy to AFMultipartFormData, in order to…
mattt authored
378 - (void)appendPartWithFile:(NSURL *)fileURL mimeType:(NSString *)mimeType fileName:(NSString *)fileName error:(NSError **)error;
4f070b2 @teeman file data upload fix
teeman authored
379
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
380 /**
381 Appends encoded data to the form data.
382
383 @param data The data to be encoded and appended to the form data.
384 */
8b86051 @mattt Replacing NSMutableURLRequest category method with more flexible cons…
mattt authored
385 - (void)appendData:(NSData *)data;
e21a7b5 @mattt Updating and completing documentation for AFHTTPClient
mattt authored
386
387 /**
388 Appends a string to the form data.
389
390 @param string The string to be encoded and appended to the form data.
391 */
8b86051 @mattt Replacing NSMutableURLRequest category method with more flexible cons…
mattt authored
392 - (void)appendString:(NSString *)string;
393 @end
ccdc5f2 @mattt Approaching a reasonable design for restructuring AFHTTPRequestOperat…
mattt authored
394
Something went wrong with that request. Please try again.