http_request Class Reference
| Inherits from | NSObject |
| Declared in | http_request.h |
Tasks
-
bodyParserproperty -
bodySerializerproperty -
responseValidatorproperty -
+ isInformationalStatusCode: -
+ isSuccessStatusCode: -
+ isRedirectionStatusCode: -
+ isClientErrorStatusCode: -
+ isServerErrorStatusCode: -
+ constructRequest:withUrl:withHeaders:withBody: -
+ isValidResponse:withBody:error: -
+ parseBody:withBody:error: -
+ serializeBody:error: -
+ jsonDataParser:error: -
+ stringDataParser:error: -
+ serializeString:error: -
+ serializeJson:error: -
– init -
– initWithConfiguration: -
– getAsync:onSuccess:onError: -
– getAsync:withHeaders:onSuccess:onError: -
– putAsync:withBody:onSuccess:onError: -
– putAsync:withString:onSuccess:onError: -
– putAsync:withJson:onSuccess:onError: -
– putAsync:withHeaders:withBody:onSuccess:onError: -
– putAsync:withHeaders:withString:onSuccess:onError: -
– putAsync:withHeaders:withJson:onSuccess:onError: -
– postAsync:withBody:onSuccess:onError: -
– postAsync:withString:onSuccess:onError: -
– postAsync:withJson:onSuccess:onError: -
– postAsync:withHeaders:withBody:onSuccess:onError: -
– postAsync:withHeaders:withString:onSuccess:onError: -
– postAsync:withHeaders:withJson:onSuccess:onError: -
– patchAsync:withBody:onSuccess:onError: -
– patchAsync:withString:onSuccess:onError: -
– patchAsync:withJson:onSuccess:onError: -
– patchAsync:withHeaders:withBody:onSuccess:onError: -
– patchAsync:withHeaders:withString:onSuccess:onError: -
– patchAsync:withHeaders:withJson:onSuccess:onError: -
– deleteAsync:onSuccess:onError: -
– deleteAsync:withHeaders:onSuccess:onError: -
– issueAsync:onSuccess:onError: -
– issueAsync:withBodyParser:withResponseValidation:onSuccess:onError:
Properties
bodyParser
The body parser block property.
@property (copy) id ( ^ ) ( NSURLResponse *, NSData *, NSError *__autoreleasing *) bodyParserDeclared In
http_request.hClass Methods
constructRequest:withUrl:withHeaders:withBody:
Constructs an HTTP request given the provided parameters.
+ (NSMutableURLRequest *)constructRequest:(NSString *)method withUrl:(NSURL *)url withHeaders:(NSDictionary *)headers withBody:(NSData *)dataParameters
- method
The HTTP method (e.g. @“GET”, @“PUT”, @“POST, @"PATCH”, @“DELETE”, …). Must not be nil.
- url
The uniform resource locator to retrieve the content from. Must not be nil.
- headers
The HTTP headers to provide as part of the request. Optional, can be nil.
- data
The data to use in the body of the request. Optional, can be nil.
Return Value
The constructed HTTP request.
Declared In
http_request.hisClientErrorStatusCode:
Determines whether or not the status code is a client error.
+ (BOOL)isClientErrorStatusCode:(int)statusCodeParameters
- statusCode
The HTTP status code.
Return Value
YES if it is a client error; otherwise, NO.
Declared In
http_request.hisInformationalStatusCode:
Determines whether or not the status code is informational.
+ (BOOL)isInformationalStatusCode:(int)statusCodeParameters
- statusCode
The HTTP status code.
Return Value
YES if it is informational; otherwise, NO.
Declared In
http_request.hisRedirectionStatusCode:
Determines whether or not the status code is redirection.
+ (BOOL)isRedirectionStatusCode:(int)statusCodeParameters
- statusCode
The HTTP status code.
Return Value
YES if it is redirection; otherwise, NO.
Declared In
http_request.hisServerErrorStatusCode:
Determines whether or not the status code is a server error.
+ (BOOL)isServerErrorStatusCode:(int)statusCodeParameters
- statusCode
The HTTP status code.
Return Value
YES if it is a server error; otherwise, NO.
Declared In
http_request.hisSuccessStatusCode:
Determines whether or not the status code is successful.
+ (BOOL)isSuccessStatusCode:(int)statusCodeParameters
- statusCode
The HTTP status code.
Return Value
YES if it is successful; otherwise, NO.
Declared In
http_request.hisValidResponse:withBody:error:
Validates the HTTP response of a request.
+ (BOOL)isValidResponse:(NSURLResponse *)response withBody:(id)body error:(NSError *__autoreleasing *)errorParameters
- response
The response to validate. Must not be nil.
- body
The response body. Optional, can be nil.
- error
The error, if any. Must not be nil.
Return Value
Determines whether there was a reponse error or not.
Declared In
http_request.hjsonDataParser:error:
Converts the provided NSData into its JSON representation.
+ (id)jsonDataParser:(NSData *)data error:(NSError *__autoreleasing *)errorParameters
- data
The data to parse. Optional, can be nil.
- error
The error, if any. Must not be nil.
Return Value
The NSDictionary representing the parsed data.
Declared In
http_request.hparseBody:withBody:error:
Parses the data given a response.
+ (id)parseBody:(NSURLResponse *)response withBody:(NSData *)data error:(NSError *__autoreleasing *)errorParameters
- response
The response. Must not be nil.
- data
The data to parse as the body. Optional, can be nil.
- error
The error, if any. Must not be nil.
Return Value
The parsed body in its corresponding representation.
Declared In
http_request.hserializeBody:error:
Serializes the body for a request.
+ (NSData *)serializeBody:(id)body error:(NSError *__autoreleasing *)errorParameters
- body
The data to serialize as the body. Optional, can be nil.
- error
The error, if any. Must not be nil.
Return Value
The serialized body in its corresponding representation.
Declared In
http_request.hserializeJson:error:
Converts the provided JSON into its NSData representation.
+ (NSData *)serializeJson:(NSDictionary *)dict error:(NSError *__autoreleasing *)errorParameters
- dict
The JSON to serialize. Optional, can be nil.
- error
The error, if any. Must not be nil.
Return Value
The NSData representing the serialized JSON.
Declared In
http_request.hserializeString:error:
Converts the provided String into its NSData representation.
+ (NSData *)serializeString:(NSString *)str error:(NSError *__autoreleasing *)errorParameters
- str
The String to serialize. Optional, can be nil.
- error
The error, if any. Must not be nil.
Return Value
The NSData representing the serialized String.
Declared In
http_request.hstringDataParser:error:
Converts the provided NSData into its String representation.
+ (id)stringDataParser:(NSData *)data error:(NSError *__autoreleasing *)errorParameters
- data
The data to parse. Optional, can be nil.
- error
The error, if any. Must not be nil.
Return Value
The NSString representing the parsed data.
Declared In
http_request.hInstance Methods
deleteAsync:onSuccess:onError:
Removes the content for the provided url.
- (NSURLSessionDataTask *)deleteAsync:(NSURL *)url onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to retrieve the content from. Must not be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hdeleteAsync:withHeaders:onSuccess:onError:
Removes the content for the provided url.
- (NSURLSessionDataTask *)deleteAsync:(NSURL *)url withHeaders:(NSDictionary *)headers onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to retrieve the content from. Must not be nil.
- headers
The HTTP headers to provide as part of the request. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hgetAsync:onSuccess:onError:
Get the content for the provided url.
- (NSURLSessionDataTask *)getAsync:(NSURL *)url onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to retrieve the content from. Must not be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hgetAsync:withHeaders:onSuccess:onError:
Get the content for the provided url.
- (NSURLSessionDataTask *)getAsync:(NSURL *)url withHeaders:(NSDictionary *)headers onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to retrieve the content from. Must not be nil.
- headers
The HTTP headers to provide as part of the request. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hinit
The default instance initializer.
- (id)initReturn Value
An instance of class.
Declared In
http_request.hinitWithConfiguration:
Initializes the instance with a provided configuration.
- (id)initWithConfiguration:(NSURLSessionConfiguration *)sessionConfigurationParameters
- sessionConfiguration
The session configuration used to initialize the instance.
Return Value
An instance of class.
Declared In
http_request.hissueAsync:onSuccess:onError:
Issues an HTTP request, parses the response body and validates the status code.
- (NSURLSessionDataTask *)issueAsync:(NSMutableURLRequest *)request onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- request
The HTTP request to issue. Must not be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hissueAsync:withBodyParser:withResponseValidation:onSuccess:onError:
Issues an HTTP request, parses the response body and validates the status code.
- (NSURLSessionDataTask *)issueAsync:(NSMutableURLRequest *)request withBodyParser:(id ( ^ ) ( NSURLResponse *, NSData *, NSError *__autoreleasing *))bodyParser withResponseValidation:(BOOL ( ^ ) ( NSURLResponse *, id , NSError *__autoreleasing *))validateResponse onSuccess:(void ( ^ ) ( NSURLResponse *, id ))successCallback onError:(void ( ^ ) ( NSError *))errorCallbackParameters
- request
The HTTP request to issue. Must not be nil.
- bodyParser
The parser used to convert the body. Optional, can be nil.
- validateResponse
The validator used to check the response. Optional, can be nil.
- successCallback
The callback called upon success; passes the response and the body. Must not be nil.
- errorCallback
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpatchAsync:withBody:onSuccess:onError:
Patch the content for the provided url.
- (NSURLSessionDataTask *)patchAsync:(NSURL *)url withBody:(NSData *)data onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- data
The NSData to be used as the body of the request and with which to patch the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpatchAsync:withHeaders:withBody:onSuccess:onError:
Patch the content for the provided url.
- (NSURLSessionDataTask *)patchAsync:(NSURL *)url withHeaders:(NSDictionary *)headers withBody:(NSData *)data onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- headers
The NSDitionary representing the headers to set for the request. Optional, can be nil.
- data
The NSData to be used as the body of the request and with which to patch the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpatchAsync:withHeaders:withJson:onSuccess:onError:
Patch the content for the provided url.
- (NSURLSessionDataTask *)patchAsync:(NSURL *)url withHeaders:(NSDictionary *)headers withJson:(NSDictionary *)dict onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- headers
The NSDitionary representing the headers to set for the request. Optional, can be nil.
- dict
The NSDictionary to be used as the body of the request and with which to patch the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpatchAsync:withHeaders:withString:onSuccess:onError:
Patch the content for the provided url.
- (NSURLSessionDataTask *)patchAsync:(NSURL *)url withHeaders:(NSDictionary *)headers withString:(NSString *)str onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- headers
The NSDitionary representing the headers to set for the request. Optional, can be nil.
- str
The NSString to be used as the body of the request and with which to patch the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpatchAsync:withJson:onSuccess:onError:
Patch the content for the provided url.
- (NSURLSessionDataTask *)patchAsync:(NSURL *)url withJson:(NSDictionary *)dict onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- dict
The NSDictionary to be used as the body of the request and with which to patch the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpatchAsync:withString:onSuccess:onError:
Patch the content for the provided url.
- (NSURLSessionDataTask *)patchAsync:(NSURL *)url withString:(NSString *)str onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- str
The NSString to be used as the body of the request and with which to patch the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpostAsync:withBody:onSuccess:onError:
Post the content for the provided url.
- (NSURLSessionDataTask *)postAsync:(NSURL *)url withBody:(NSData *)data onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- data
The NSData to be used as the body of the request and with which to post the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpostAsync:withHeaders:withBody:onSuccess:onError:
Post the content for the provided url.
- (NSURLSessionDataTask *)postAsync:(NSURL *)url withHeaders:(NSDictionary *)headers withBody:(NSData *)data onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- headers
The NSDitionary representing the headers to set for the request. Optional, can be nil.
- data
The NSData to be used as the body of the request and with which to post the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpostAsync:withHeaders:withJson:onSuccess:onError:
Post the content for the provided url.
- (NSURLSessionDataTask *)postAsync:(NSURL *)url withHeaders:(NSDictionary *)headers withJson:(NSDictionary *)dict onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- headers
The NSDitionary representing the headers to set for the request. Optional, can be nil.
- dict
The NSDictionary to be used as the body of the request and with which to post the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpostAsync:withHeaders:withString:onSuccess:onError:
Post the content for the provided url.
- (NSURLSessionDataTask *)postAsync:(NSURL *)url withHeaders:(NSDictionary *)headers withString:(NSString *)str onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- headers
The NSDitionary representing the headers to set for the request. Optional, can be nil.
- str
The NSString to be used as the body of the request and with which to post the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpostAsync:withJson:onSuccess:onError:
Post the content for the provided url.
- (NSURLSessionDataTask *)postAsync:(NSURL *)url withJson:(NSDictionary *)dict onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- dict
The NSDictionary to be used as the body of the request and with which to post the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hpostAsync:withString:onSuccess:onError:
Post the content for the provided url.
- (NSURLSessionDataTask *)postAsync:(NSURL *)url withString:(NSString *)str onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- str
The NSString to be used as the body of the request and with which to post the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hputAsync:withBody:onSuccess:onError:
Put the content for the provided url.
- (NSURLSessionDataTask *)putAsync:(NSURL *)url withBody:(NSData *)data onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- data
The NSData to be used as the body of the request and with which to put the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hputAsync:withHeaders:withBody:onSuccess:onError:
Put the content for the provided url.
- (NSURLSessionDataTask *)putAsync:(NSURL *)url withHeaders:(NSDictionary *)headers withBody:(NSData *)data onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- headers
The NSDitionary representing the headers to set for the request. Optional, can be nil.
- data
The NSData to be used as the body of the request and with which to put the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hputAsync:withHeaders:withJson:onSuccess:onError:
Put the content for the provided url.
- (NSURLSessionDataTask *)putAsync:(NSURL *)url withHeaders:(NSDictionary *)headers withJson:(NSDictionary *)dict onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- headers
The NSDitionary representing the headers to set for the request. Optional, can be nil.
- dict
The NSDictionary to be used as the body of the request and with which to put the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hputAsync:withHeaders:withString:onSuccess:onError:
Put the content for the provided url.
- (NSURLSessionDataTask *)putAsync:(NSURL *)url withHeaders:(NSDictionary *)headers withString:(NSString *)str onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- headers
The NSDitionary representing the headers to set for the request. Optional, can be nil.
- str
The NSString to be used as the body of the request and with which to put the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hputAsync:withJson:onSuccess:onError:
Put the content for the provided url.
- (NSURLSessionDataTask *)putAsync:(NSURL *)url withJson:(NSDictionary *)dict onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- dict
The NSDictionary to be used as the body of the request and with which to put the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.hputAsync:withString:onSuccess:onError:
Put the content for the provided url.
- (NSURLSessionDataTask *)putAsync:(NSURL *)url withString:(NSString *)str onSuccess:(void ( ^ ) ( NSURLResponse *, id ))success onError:(void ( ^ ) ( NSError *))errorParameters
- url
The uniform resource locator to update the content with. Must not be nil.
- str
The NSString to be used as the body of the request and with which to put the url with. Optional, can be nil.
- success
The callback called upon success; passes the response and the body. Must not be nil.
- error
The callback called upon error; passes an NSError. Must not be nil.
Return Value
The task representing the operation.
Declared In
http_request.h