afmotion 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +1 -1
  3. data/Gemfile.lock +21 -28
  4. data/lib/afmotion/patch/NSURLRequest_params.rb +4 -2
  5. data/lib/afmotion/version.rb +1 -1
  6. metadata +2 -53
  7. data/vendor/Pods/AFNetworking/AFNetworking.podspec +0 -28
  8. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +0 -574
  9. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +0 -1187
  10. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +0 -133
  11. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +0 -341
  12. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +0 -108
  13. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +0 -237
  14. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +0 -71
  15. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +0 -136
  16. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  17. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +0 -131
  18. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +0 -44
  19. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  20. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +0 -145
  21. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +0 -295
  22. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +0 -652
  23. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +0 -89
  24. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +0 -169
  25. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +0 -78
  26. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +0 -180
  27. data/vendor/Pods/AFNetworking/LICENSE +0 -19
  28. data/vendor/Pods/AFNetworking/README.md +0 -179
  29. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +0 -574
  30. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +0 -133
  31. data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +0 -108
  32. data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +0 -71
  33. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  34. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +0 -44
  35. data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  36. data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +0 -295
  37. data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +0 -89
  38. data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +0 -78
  39. data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +0 -574
  40. data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +0 -133
  41. data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +0 -108
  42. data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +0 -71
  43. data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  44. data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +0 -44
  45. data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  46. data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +0 -295
  47. data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +0 -89
  48. data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +0 -78
  49. data/vendor/Pods/Pods-Acknowledgements.markdown +0 -26
  50. data/vendor/Pods/Pods-Acknowledgements.plist +0 -56
  51. data/vendor/Pods/Pods-prefix.pch +0 -14
  52. data/vendor/Pods/Pods-resources.sh +0 -19
  53. data/vendor/Pods/Pods.bridgesupport +0 -617
  54. data/vendor/Pods/Pods.xcconfig +0 -7
  55. data/vendor/Pods/PodsDummy_Pods.m +0 -4
@@ -1,574 +0,0 @@
1
- // AFHTTPClient.h
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
-
25
- /**
26
- `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.
27
-
28
- ## Automatic Content Parsing
29
-
30
- 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 in `enqueueHTTPRequestOperationWithRequest:success:failure`.
31
-
32
- ## Subclassing Notes
33
-
34
- 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.
35
-
36
- ## Methods to Override
37
-
38
- To change the behavior of all url request construction for an `AFHTTPClient` subclass, override `requestWithMethod:path:parameters`.
39
-
40
- To change the behavior of all request operation construction for an `AFHTTPClient` subclass, override `HTTPRequestOperationWithRequest:success:failure`.
41
-
42
- ## Default Headers
43
-
44
- By default, `AFHTTPClient` sets the following HTTP headers:
45
-
46
- - `Accept-Encoding: gzip`
47
- - `Accept-Language: (comma-delimited preferred languages), en-us;q=0.8`
48
- - `User-Agent: (generated user agent)`
49
-
50
- You can override these HTTP headers or define new ones using `setDefaultHeader:value:`.
51
-
52
- ## URL Construction Using Relative Paths
53
-
54
- Both `-requestWithMethod:path:parameters:` and `-multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:` construct URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`. Below are a few examples of how `baseURL` and relative paths interact:
55
-
56
- NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
57
- [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo
58
- [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz
59
- [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo
60
- [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo
61
- [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/
62
- [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
63
-
64
- Also important to note is that a trailing slash will be added to any `baseURL` without one, which would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.
65
-
66
- ## NSCoding / NSCopying Conformance
67
-
68
- `AFHTTPClient` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however:
69
-
70
- - Archives and copies of HTTP clients will be initialized with an empty operation queue.
71
- - NSCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set.
72
- */
73
-
74
- #ifdef _SYSTEMCONFIGURATION_H
75
- typedef enum {
76
- AFNetworkReachabilityStatusUnknown = -1,
77
- AFNetworkReachabilityStatusNotReachable = 0,
78
- AFNetworkReachabilityStatusReachableViaWWAN = 1,
79
- AFNetworkReachabilityStatusReachableViaWiFi = 2,
80
- } AFNetworkReachabilityStatus;
81
- #else
82
- #warning "SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available."
83
- #endif
84
-
85
- #ifndef __UTTYPE__
86
- #warning "CoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available."
87
- #endif
88
-
89
- typedef enum {
90
- AFFormURLParameterEncoding,
91
- AFJSONParameterEncoding,
92
- AFPropertyListParameterEncoding,
93
- } AFHTTPClientParameterEncoding;
94
-
95
- @class AFHTTPRequestOperation;
96
- @protocol AFMultipartFormData;
97
-
98
- @interface AFHTTPClient : NSObject <NSCoding, NSCopying>
99
-
100
- ///---------------------------------------
101
- /// @name Accessing HTTP Client Properties
102
- ///---------------------------------------
103
-
104
- /**
105
- The url used as the base for paths specified in methods such as `getPath:parameters:success:failure`
106
- */
107
- @property (readonly, nonatomic) NSURL *baseURL;
108
-
109
- /**
110
- The string encoding used in constructing url requests. This is `NSUTF8StringEncoding` by default.
111
- */
112
- @property (nonatomic, assign) NSStringEncoding stringEncoding;
113
-
114
- /**
115
- The `AFHTTPClientParameterEncoding` value corresponding to how parameters are encoded into a request body. This is `AFFormURLParameterEncoding` by default.
116
- */
117
- @property (nonatomic, assign) AFHTTPClientParameterEncoding parameterEncoding;
118
-
119
- /**
120
- The operation queue which manages operations enqueued by the HTTP client.
121
- */
122
- @property (readonly, nonatomic) NSOperationQueue *operationQueue;
123
-
124
- /**
125
- The reachability status from the device to the current `baseURL` of the `AFHTTPClient`.
126
-
127
- @warning This property requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
128
- */
129
- #ifdef _SYSTEMCONFIGURATION_H
130
- @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
131
- #endif
132
-
133
- ///---------------------------------------------
134
- /// @name Creating and Initializing HTTP Clients
135
- ///---------------------------------------------
136
-
137
- /**
138
- Creates and initializes an `AFHTTPClient` object with the specified base URL.
139
-
140
- @param url The base URL for the HTTP client. This argument must not be `nil`.
141
-
142
- @return The newly-initialized HTTP client
143
- */
144
- + (AFHTTPClient *)clientWithBaseURL:(NSURL *)url;
145
-
146
- /**
147
- Initializes an `AFHTTPClient` object with the specified base URL.
148
-
149
- @param url The base URL for the HTTP client. This argument must not be `nil`.
150
-
151
- @discussion This is the designated initializer.
152
-
153
- @return The newly-initialized HTTP client
154
- */
155
- - (id)initWithBaseURL:(NSURL *)url;
156
-
157
- ///-----------------------------------
158
- /// @name Managing Reachability Status
159
- ///-----------------------------------
160
-
161
- /**
162
- Sets a callback to be executed when the network availability of the `baseURL` host changes.
163
-
164
- @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
165
-
166
- @warning This method requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
167
- */
168
- #ifdef _SYSTEMCONFIGURATION_H
169
- - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block;
170
- #endif
171
-
172
- ///-------------------------------
173
- /// @name Managing HTTP Operations
174
- ///-------------------------------
175
-
176
- /**
177
- Attempts to register a subclass of `AFHTTPRequestOperation`, adding it to a chain to automatically generate request operations from a URL request.
178
-
179
- @param operationClass The subclass of `AFHTTPRequestOperation` to register
180
-
181
- @return `YES` if the registration is successful, `NO` otherwise. The only failure condition is if `operationClass` is not a subclass of `AFHTTPRequestOperation`.
182
-
183
- @discussion When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list.
184
- */
185
- - (BOOL)registerHTTPOperationClass:(Class)operationClass;
186
-
187
- /**
188
- Unregisters the specified subclass of `AFHTTPRequestOperation` from the chain of classes consulted when `-requestWithMethod:path:parameters` is called.
189
-
190
- @param operationClass The subclass of `AFHTTPRequestOperation` to register
191
- */
192
- - (void)unregisterHTTPOperationClass:(Class)operationClass;
193
-
194
- ///----------------------------------
195
- /// @name Managing HTTP Header Values
196
- ///----------------------------------
197
-
198
- /**
199
- Returns the value for the HTTP headers set in request objects created by the HTTP client.
200
-
201
- @param header The HTTP header to return the default value for
202
-
203
- @return The default value for the HTTP header, or `nil` if unspecified
204
- */
205
- - (NSString *)defaultValueForHeader:(NSString *)header;
206
-
207
- /**
208
- 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.
209
-
210
- @param header The HTTP header to set a default value for
211
- @param value The value set as default for the specified header, or `nil
212
- */
213
- - (void)setDefaultHeader:(NSString *)header value:(NSString *)value;
214
-
215
- /**
216
- 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.
217
-
218
- @param username The HTTP basic auth username
219
- @param password The HTTP basic auth password
220
- */
221
- - (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password;
222
-
223
- /**
224
- 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.
225
-
226
- @param token The authentication token
227
- */
228
- - (void)setAuthorizationHeaderWithToken:(NSString *)token;
229
-
230
- /**
231
- Clears any existing value for the "Authorization" HTTP header.
232
- */
233
- - (void)clearAuthorizationHeader;
234
-
235
- ///-------------------------------
236
- /// @name Creating Request Objects
237
- ///-------------------------------
238
-
239
- /**
240
- Creates an `NSMutableURLRequest` object with the specified HTTP method and path.
241
-
242
- 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.
243
-
244
- @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`.
245
- @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.
246
- @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
247
-
248
- @return An `NSMutableURLRequest` object
249
- */
250
- - (NSMutableURLRequest *)requestWithMethod:(NSString *)method
251
- path:(NSString *)path
252
- parameters:(NSDictionary *)parameters;
253
-
254
- /**
255
- 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
256
-
257
- @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`.
258
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
259
- @param parameters The parameters to be encoded and set in the request HTTP body.
260
- @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.
261
-
262
- @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.
263
-
264
- @return An `NSMutableURLRequest` object
265
- */
266
- - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
267
- path:(NSString *)path
268
- parameters:(NSDictionary *)parameters
269
- constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block;
270
-
271
- ///-------------------------------
272
- /// @name Creating HTTP Operations
273
- ///-------------------------------
274
-
275
- /**
276
- Creates an `AFHTTPRequestOperation`.
277
-
278
- In order to determine what kind of operation is created, each registered subclass conforming to the `AFHTTPClient` protocol is consulted (in reverse order of when they were specified) to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to generate an operation using `HTTPRequestOperationWithRequest:success:failure:`.
279
-
280
- @param urlRequest The request object to be loaded asynchronously during execution of the operation.
281
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
282
- @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 response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
283
- */
284
- - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest
285
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
286
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
287
-
288
- ///----------------------------------------
289
- /// @name Managing Enqueued HTTP Operations
290
- ///----------------------------------------
291
-
292
- /**
293
- Enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue.
294
-
295
- @param operation The HTTP request operation to be enqueued.
296
- */
297
- - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation;
298
-
299
- /**
300
- Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path.
301
-
302
- @param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled.
303
- @param path The path appended to the HTTP client base URL to match against the cancelled requests. If `nil`, no path will be appended to the base URL.
304
-
305
- @discussion This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property.
306
- */
307
- - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path;
308
-
309
- ///---------------------------------------
310
- /// @name Batching HTTP Request Operations
311
- ///---------------------------------------
312
-
313
- /**
314
- Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue for each specified request object into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
315
-
316
- @param urlRequests The `NSURLRequest` objects used to create and enqueue operations.
317
- @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
318
- @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations.
319
-
320
- @discussion Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters.
321
- */
322
- - (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests
323
- progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
324
- completionBlock:(void (^)(NSArray *operations))completionBlock;
325
-
326
- /**
327
- Enqueues the specified request operations into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
328
-
329
- @param operations The request operations used to be batched and enqueued.
330
- @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
331
- @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations.
332
- */
333
- - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations
334
- progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
335
- completionBlock:(void (^)(NSArray *operations))completionBlock;
336
-
337
- ///---------------------------
338
- /// @name Making HTTP Requests
339
- ///---------------------------
340
-
341
- /**
342
- Creates an `AFHTTPRequestOperation` with a `GET` request, and enqueues it to the HTTP client's operation queue.
343
-
344
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
345
- @param parameters The parameters to be encoded and appended as the query string for the request URL.
346
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
347
- @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 response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
348
-
349
- @see -HTTPRequestOperationWithRequest:success:failure:
350
- */
351
- - (void)getPath:(NSString *)path
352
- parameters:(NSDictionary *)parameters
353
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
354
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
355
-
356
- /**
357
- Creates an `AFHTTPRequestOperation` with a `POST` request, and enqueues it to the HTTP client's operation queue.
358
-
359
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
360
- @param parameters The parameters to be encoded and set in the request HTTP body.
361
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
362
- @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 response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
363
-
364
- @see -HTTPRequestOperationWithRequest:success:failure:
365
- */
366
- - (void)postPath:(NSString *)path
367
- parameters:(NSDictionary *)parameters
368
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
369
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
370
-
371
- /**
372
- Creates an `AFHTTPRequestOperation` with a `PUT` request, and enqueues it to the HTTP client's operation queue.
373
-
374
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
375
- @param parameters The parameters to be encoded and set in the request HTTP body.
376
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
377
- @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 response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
378
-
379
- @see -HTTPRequestOperationWithRequest:success:failure:
380
- */
381
- - (void)putPath:(NSString *)path
382
- parameters:(NSDictionary *)parameters
383
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
384
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
385
-
386
- /**
387
- Creates an `AFHTTPRequestOperation` with a `DELETE` request, and enqueues it to the HTTP client's operation queue.
388
-
389
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
390
- @param parameters The parameters to be encoded and appended as the query string for the request URL.
391
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
392
- @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 response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
393
-
394
- @see -HTTPRequestOperationWithRequest:success:failure:
395
- */
396
- - (void)deletePath:(NSString *)path
397
- parameters:(NSDictionary *)parameters
398
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
399
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
400
-
401
- /**
402
- Creates an `AFHTTPRequestOperation` with a `PATCH` request, and enqueues it to the HTTP client's operation queue.
403
-
404
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
405
- @param parameters The parameters to be encoded and set in the request HTTP body.
406
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
407
- @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 response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
408
-
409
- @see -HTTPRequestOperationWithRequest:success:failure:
410
- */
411
- - (void)patchPath:(NSString *)path
412
- parameters:(NSDictionary *)parameters
413
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
414
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
415
- @end
416
-
417
- ///----------------
418
- /// @name Constants
419
- ///----------------
420
-
421
- /**
422
- ### Network Reachability
423
-
424
- The following constants are provided by `AFHTTPClient` as possible network reachability statuses.
425
-
426
- enum {
427
- AFNetworkReachabilityStatusUnknown,
428
- AFNetworkReachabilityStatusNotReachable,
429
- AFNetworkReachabilityStatusReachableViaWWAN,
430
- AFNetworkReachabilityStatusReachableViaWiFi,
431
- }
432
-
433
- `AFNetworkReachabilityStatusUnknown`
434
- The `baseURL` host reachability is not known.
435
-
436
- `AFNetworkReachabilityStatusNotReachable`
437
- The `baseURL` host cannot be reached.
438
-
439
- `AFNetworkReachabilityStatusReachableViaWWAN`
440
- The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
441
-
442
- `AFNetworkReachabilityStatusReachableViaWiFi`
443
- The `baseURL` host can be reached via a Wi-Fi connection.
444
-
445
- ### Keys for Notification UserInfo Dictionary
446
-
447
- Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
448
-
449
- `AFNetworkingReachabilityNotificationStatusItem`
450
- A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
451
- The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
452
-
453
- ### Parameter Encoding
454
-
455
- The following constants are provided by `AFHTTPClient` as possible methods for serializing parameters into query string or message body values.
456
-
457
- enum {
458
- AFFormURLParameterEncoding,
459
- AFJSONParameterEncoding,
460
- AFPropertyListParameterEncoding,
461
- }
462
-
463
- `AFFormURLParameterEncoding`
464
- Parameters are encoded into field/key pairs in the URL query string for `GET` `HEAD` and `DELETE` requests, and in the message body otherwise.
465
-
466
- `AFJSONParameterEncoding`
467
- Parameters are encoded into JSON in the message body.
468
-
469
- `AFPropertyListParameterEncoding`
470
- Parameters are encoded into a property list in the message body.
471
- */
472
-
473
- ///----------------
474
- /// @name Functions
475
- ///----------------
476
-
477
- /**
478
- Returns a query string constructed by a set of parameters, using the specified encoding.
479
-
480
- @param parameters The parameters used to construct the query string
481
- @param encoding The encoding to use in constructing the query string. If you are uncertain of the correct encoding, you should use UTF-8 (`NSUTF8StringEncoding`), which is the encoding designated by RFC 3986 as the correct encoding for use in URLs.
482
-
483
- @discussion Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&".
484
-
485
- If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component.
486
-
487
- @return A percent-escaped query string
488
- */
489
- extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding);
490
-
491
- ///--------------------
492
- /// @name Notifications
493
- ///--------------------
494
-
495
- /**
496
- Posted when network reachability changes.
497
- This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
498
-
499
- @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
500
- */
501
- #ifdef _SYSTEMCONFIGURATION_H
502
- extern NSString * const AFNetworkingReachabilityDidChangeNotification;
503
- extern NSString * const AFNetworkingReachabilityNotificationStatusItem;
504
- #endif
505
-
506
- #pragma mark -
507
-
508
- extern NSUInteger const kAFUploadStream3GSuggestedPacketSize;
509
- extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
510
-
511
- /**
512
- The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPClient -multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:`.
513
- */
514
- @protocol AFMultipartFormData
515
-
516
- /**
517
- Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary.
518
-
519
- @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
520
- @param name The name to be associated with the specified data. This parameter must not be `nil`.
521
- @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
522
-
523
- @return `YES` if the file data was successfully appended, otherwise `NO`.
524
-
525
- @discussion The filename and MIME type for this data in the form will be automatically generated, using `NSURLResponse` `-suggestedFilename` and `-MIMEType`, respectively.
526
- */
527
- - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
528
- name:(NSString *)name
529
- error:(NSError * __autoreleasing *)error;
530
-
531
- /**
532
- Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
533
-
534
- @param data The data to be encoded and appended to the form data.
535
- @param name The name to be associated with the specified data. This parameter must not be `nil`.
536
- @param filename The filename to be associated with the specified data. This parameter must not be `nil`.
537
- @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`.
538
- */
539
- - (void)appendPartWithFileData:(NSData *)data
540
- name:(NSString *)name
541
- fileName:(NSString *)fileName
542
- mimeType:(NSString *)mimeType;
543
-
544
- /**
545
- Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
546
-
547
- @param data The data to be encoded and appended to the form data.
548
- @param name The name to be associated with the specified data. This parameter must not be `nil`.
549
- */
550
-
551
- - (void)appendPartWithFormData:(NSData *)data
552
- name:(NSString *)name;
553
-
554
- /**
555
- Appends HTTP headers, followed by the encoded data and the multipart form boundary.
556
-
557
- @param headers The HTTP headers to be appended to the form data.
558
- @param body The data to be encoded and appended to the form data.
559
- */
560
- - (void)appendPartWithHeaders:(NSDictionary *)headers
561
- body:(NSData *)body;
562
-
563
- /**
564
- Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
565
-
566
- @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 32kb.
567
- @param delay Duration of delay each time a packet is read. By default, no delay is set.
568
-
569
- @discussion When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
570
- */
571
- - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
572
- delay:(NSTimeInterval)delay;
573
-
574
- @end