Inherits from NSObject
Declared in WLResourceRequest.h

Overview

This class encapsulates a resource request. The resource may be an adapter on the MobileFirst server, or an external resource. The class provides several ‘send’ methods, with different inputs for the body of a request.

Properties

headers

Array of request headers

@property (nonatomic) NSArray *headers

Declared In

WLResourceRequest.h

httpMethod

HTTP method of the request

@property (readonly) NSString *httpMethod

Declared In

WLResourceRequest.h

queryParameters

Dictionary of query parameters

@property (nonatomic) NSDictionary *queryParameters

Declared In

WLResourceRequest.h

stringEncoding

Request string encoding

@property (nonatomic, assign) NSStringEncoding stringEncoding

Declared In

WLResourceRequest.h

timeoutInterval

Request timeout interval

@property NSTimeInterval timeoutInterval

Declared In

WLResourceRequest.h

url

URL of the request

@property (readonly) NSURL *url

Declared In

WLResourceRequest.h

Class Methods

requestWithURL:method:

Creates an instance of WLresourceRequest with the specified URL and method

+ (WLResourceRequest *)requestWithURL:(NSURL *)url method:(NSString *)method

Parameters

url

URL of the request (full or relative to MobileFirst Server)

method

Method of the request (POST, GET,…)

Declared In

WLResourceRequest.h

requestWithURL:method:timeout:

Creates an instance of WLresourceRequest with the specified URL, method, and timeout

+ (WLResourceRequest *)requestWithURL:(NSURL *)url method:(NSString *)method timeout:(NSTimeInterval)timeout

Parameters

url

URL of the request (full or relative to MobileFirst Server)

method

Method of the request (POST, GET,…)

timeout

Timeout of the request in seconds

Declared In

WLResourceRequest.h

Instance Methods

addHeaderValue:forName:

Adds the header to the request

- (void)addHeaderValue:(NSObject *)value forName:(NSString *)name

Parameters

value

Header value

name

Header name

Discussion

If a header with the same name already exists, the values are concatenated and separated by commas.

Note: The header name is case insensitive.

Declared In

WLResourceRequest.h

headerForName:

Returns first header with matching name

- (NSString *)headerForName:(NSString *)name

Parameters

name

name of the header

Declared In

WLResourceRequest.h

headerNames

Returns header names as an array of strings

- (NSArray *)headerNames

Declared In

WLResourceRequest.h

headersForName:

Returns header name as an array of strings

- (NSArray *)headersForName:(NSString *)name

Parameters

name

Header name

Discussion

For a single header name, there can be several values separated by commas. If there is only one value, the method returns an array with one element.

Declared In

WLResourceRequest.h

removeHeadersForName:

Removes the header from the request

- (void)removeHeadersForName:(NSString *)name

Parameters

name

Header name

Declared In

WLResourceRequest.h

sendWithBody:completionHandler:

Sends a request with the provided text as a request body and uses a completionHandler block to handle the response

- (void)sendWithBody:(NSString *)body completionHandler:(void ( ^ ) ( WLResponse *response , NSError *error ))completionHandler

Parameters

body

Request body

completionHandler

(void(^) (WLResponse response, NSError error)) Block that is triggered when a response has been received Note: Using methods other than POST or PUT will omit the request body.

Declared In

WLResourceRequest.h

sendWithBody:delegate:

Sends a request with the provided text as a request body and uses a delegate to handle the response

- (void)sendWithBody:(NSString *)body delegate:(id)delegate

Parameters

body

Request body

delegate

Delegate that conforms to both NSURLConnectionDataDelegate and NSURLConnectionDelegate protocols Note: The delegate must implement both NSURLConnectionDataDelegate and NSURLConnectionDelegate protocols. Note: Using methods other than POST or PUT will omit the request body.

Declared In

WLResourceRequest.h

sendWithCompletionHandler:

Sends a request and uses the completionHandler block to handle the response

- (void)sendWithCompletionHandler:(void ( ^ ) ( WLResponse *response , NSError *error ))completionHandler

Parameters

completionHandler

(void(^) (WLResponse response, NSError error)) Block that is triggered when a response has been received.

Declared In

WLResourceRequest.h

sendWithData:completionHandler:

Sends a request with the provided request data and uses completionHandler block to handle the response

- (void)sendWithData:(NSData *)data completionHandler:(void ( ^ ) ( WLResponse *response , NSError *error ))completionHandler

Parameters

data

Request data

completionHandler

(void(^) (WLResponse response, NSError error)) Block that is triggered when a response has been received Note: Using methods other than POST or PUT will omit the request body.

Declared In

WLResourceRequest.h

sendWithData:delegate:

Sends a request with the provided request data and uses a delegate to handle the response

- (void)sendWithData:(NSData *)data delegate:(id)delegate

Parameters

data

Request data

delegate

Delegate that conforms to both NSURLConnectionDataDelegate and NSURLConnectionDelegate protocols Note: The delegate must implement both NSURLConnectionDataDelegate and NSURLConnectionDelegate protocols. Note: Using methods other than POST or PUT will omit the request body

Declared In

WLResourceRequest.h

sendWithDelegate:

Sends a request and uses a delegate to handle the response

- (void)sendWithDelegate:(id)delegate

Parameters

delegate

Delegate that conforms to both NSURLConnectionDataDelegate and NSURLConnectionDelegate protocols Note: The delegate must implement both NSURLConnectionDataDelegate and NSURLConnectionDelegate protocols.

Declared In

WLResourceRequest.h

sendWithFormParameters:completionHandler:

Sends a request with form parameters as a request body and uses a completionHandler block to handle the response

- (void)sendWithFormParameters:(NSDictionary *)formParameters completionHandler:(void ( ^ ) ( WLResponse *response , NSError *error ))completionHandler

Parameters

completionHandler

(void(^) (WLResponse response, NSError error)) Block that is triggered when a response has been received Note: Using methods other than POST or PUT will omit the request body.

bodyParameters

Dictionary of form parameters

Declared In

WLResourceRequest.h

sendWithFormParameters:delegate:

Sends a request with form parameters as a request body and uses a delegate to handle the response

- (void)sendWithFormParameters:(NSDictionary *)formParameters delegate:(id)delegate

Parameters

delegate

Delegate that conforms to both NSURLConnectionDataDelegate and NSURLConnectionDelegate protocols Note: The delegate must implement both NSURLConnectionDataDelegate and NSURLConnectionDelegate protocols. Note: Using methods other than POST or PUT will omit the request body.

bodyParameters

Dictionary of form parameters

Declared In

WLResourceRequest.h

sendWithJSON:completionHandler:

Sends a request with the provided JSON and uses a completionHandler block to handle the response

- (void)sendWithJSON:(NSDictionary *)json completionHandler:(void ( ^ ) ( WLResponse *response , NSError *error ))completionHandler

Parameters

json

JSON as a dictionary

completionHandler

(void(^) (WLResponse response, NSError error)) Block that is triggered when a response has been received Note: Using methods other than POST or PUT will omit the request body.

Declared In

WLResourceRequest.h

sendWithJSON:delegate:

Sends a request with the provided JSON and uses a delegate to handle the response

- (void)sendWithJSON:(NSDictionary *)json delegate:(id)delegate

Parameters

json

JSON as a dictionary

delegate

Delegate that conforms to both NSURLConnectionDataDelegate and NSURLConnectionDelegate protocols Note: The delegate must implement both NSURLConnectionDataDelegate and NSURLConnectionDelegate protocols. Note: Using methods other than POST or PUT will omit the request body.

Declared In

WLResourceRequest.h

setHeaderValue:forName:

Sets the header for the request

- (void)setHeaderValue:(NSObject *)value forName:(NSString *)name

Parameters

value

Header value

name

Header name

Discussion

If a header with the same name already exists, it is overridden.

Note: The header name is case insensitive.

Declared In

WLResourceRequest.h

setQueryParameterValue:forName:

Sets query parameter value

- (void)setQueryParameterValue:(NSString *)parameterValue forName:(NSString *)parameterName

Parameters

parameterValue

Parameter value

parameterName

Parameter name

Discussion

If the query parameter with the same name already exists, it is overridden.

Declared In

WLResourceRequest.h