|
@@ -160,11 +160,11 @@ typedef enum {
|
|
|
|
|
|
/**
|
|
|
Initializes an `AFHTTPClient` object with the specified base URL.
|
|
|
+
|
|
|
+ This is the designated initializer.
|
|
|
|
|
|
@param url The base URL for the HTTP client. This argument must not be `nil`.
|
|
|
|
|
|
- @discussion This is the designated initializer.
|
|
|
-
|
|
|
@return The newly-initialized HTTP client
|
|
|
*/
|
|
|
- (id)initWithBaseURL:(NSURL *)url;
|
|
@@ -191,11 +191,11 @@ typedef enum {
|
|
|
/**
|
|
|
Attempts to register a subclass of `AFHTTPRequestOperation`, adding it to a chain to automatically generate request operations from a URL request.
|
|
|
|
|
|
+ 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.
|
|
|
+
|
|
|
@param operationClass The subclass of `AFHTTPRequestOperation` to register
|
|
|
|
|
|
@return `YES` if the registration is successful, `NO` otherwise. The only failure condition is if `operationClass` is not a subclass of `AFHTTPRequestOperation`.
|
|
|
-
|
|
|
- @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.
|
|
|
*/
|
|
|
- (BOOL)registerHTTPOperationClass:(Class)operationClass;
|
|
|
|
|
@@ -283,13 +283,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
|
|
|
|
|
|
+ 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.
|
|
|
+
|
|
|
@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.
|
|
|
-
|
|
|
@return An `NSMutableURLRequest` object
|
|
|
*/
|
|
|
- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
|
|
@@ -327,11 +327,11 @@ typedef enum {
|
|
|
|
|
|
/**
|
|
|
Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path.
|
|
|
+
|
|
|
+ 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.
|
|
|
|
|
|
@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.
|
|
|
@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.
|
|
|
-
|
|
|
- @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.
|
|
|
*/
|
|
|
- (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path;
|
|
|
|
|
@@ -342,11 +342,11 @@ typedef enum {
|
|
|
/**
|
|
|
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.
|
|
|
|
|
|
+ Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters.
|
|
|
+
|
|
|
@param urlRequests The `NSURLRequest` objects used to create and enqueue operations.
|
|
|
@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.
|
|
|
@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.
|
|
|
-
|
|
|
- @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.
|
|
|
*/
|
|
|
- (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests
|
|
|
progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
|
|
@@ -506,13 +506,13 @@ typedef enum {
|
|
|
/**
|
|
|
Returns a query string constructed by a set of parameters, using the specified encoding.
|
|
|
|
|
|
+ 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 "&".
|
|
|
+
|
|
|
+ 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.
|
|
|
+
|
|
|
@param parameters The parameters used to construct the query string
|
|
|
@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.
|
|
|
|
|
|
- @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 "&".
|
|
|
-
|
|
|
- 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.
|
|
|
-
|
|
|
@return A percent-escaped query string
|
|
|
*/
|
|
|
extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding);
|
|
@@ -545,13 +545,13 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
|
|
|
/**
|
|
|
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.
|
|
|
|
|
|
+ The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively.
|
|
|
+
|
|
|
@param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
|
|
|
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
|
|
@param error If an error occurs, upon return contains an `NSError` object that describes the problem.
|
|
|
|
|
|
@return `YES` if the file data was successfully appended, otherwise `NO`.
|
|
|
-
|
|
|
- @discussion The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively.
|
|
|
*/
|
|
|
- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
|
|
|
name:(NSString *)name
|
|
@@ -625,10 +625,10 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
|
|
|
/**
|
|
|
Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
|
|
|
|
|
|
+ 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.
|
|
|
+
|
|
|
@param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 32kb.
|
|
|
@param delay Duration of delay each time a packet is read. By default, no delay is set.
|
|
|
-
|
|
|
- @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.
|
|
|
*/
|
|
|
- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
|
|
|
delay:(NSTimeInterval)delay;
|