VKHTTPClient Class Reference
| Inherits from | VKObject : NSObject |
| Conforms to | NSCoding |
| Declared in | VKHTTPClient.h VKHTTPClient.m |
Overview
Class for NSURLRequests generation, made for VK API. Based on AFNetworking library ( https://github.com/AFNetworking/AFNetworking )
Tasks
Initialization
-
+ getClient -
operationQueueproperty
Operations with default headers
Preparing requests
Enqueuing operations
Instance Methods
defaultValueForHeader:
Returns the value for the HTTP headers set in request objects created by the HTTP client.
- (NSString *)defaultValueForHeader:(NSString *)headerParameters
- header
The HTTP header to return the default value for
Return Value
The default value for the HTTP header, or nil if unspecified
Declared In
VKHTTPClient.henqueueBatchOfHTTPRequestOperations:progressBlock:completionBlock:
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.
- (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations progressBlock:(void ( ^ ) ( NSUInteger numberOfFinishedOperations , NSUInteger totalNumberOfOperations ))progressBlock completionBlock:(void ( ^ ) ( NSArray *operations ))completionBlockParameters
- operations
The request operations used to be batched and enqueued.
- 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.
- 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.
Declared In
VKHTTPClient.henqueueOperation:
Enqueues an AFHTTPRequestOperation to the HTTP client’s operation queue.
- (void)enqueueOperation:(NSOperation *)operationParameters
- operation
The HTTP request operation to be enqueued.
Declared In
VKHTTPClient.hmultipartFormRequestWithMethod:path:images:
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
- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method path:(NSString *)path images:(NSArray *)imagesParameters
- method
The HTTP method for the request. This parameter must not be
GETorHEAD, ornil.
- path
The path to be appended to the HTTP client’s base URL and used as the request URL.
- images
Upload images objects to append
Return Value
An NSMutableURLRequest object
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.
Declared In
VKHTTPClient.hrequestWithMethod:path:parameters:secure:
Creates an NSMutableURLRequest object with the specified HTTP method and path.
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method path:(NSString *)path parameters:(NSDictionary *)parameters secure:(BOOL)secureParameters
- method
The HTTP method for the request, such as
GET,POST,PUT, orDELETE. This parameter must not benil.
- 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.
- parameters
The parameters to be either set as a query string for
GETrequests, or the request HTTP body.
- secure
Use HTTPS or not
Return Value
An NSMutableURLRequest object
Discussion
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.
Declared In
VKHTTPClient.hsetDefaultHeader:value:
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.
- (void)setDefaultHeader:(NSString *)header value:(NSString *)valueParameters
- header
The HTTP header to set a default value for
- value
The value set as default for the specified header, or `nil
Declared In
VKHTTPClient.h