Android Client SDK
com.verivo.akula.http.AKHttpAgent Class Reference

The AKHttpAgent class builds, executes, and manages HTTP requests. More...

Inheritance diagram for com.verivo.akula.http.AKHttpAgent:
Inheritance graph

Public Member Functions

 AKHttpAgent ()
 Constructor. More...
 
void delete (String url, AKHttpResponseHandler responseHandler)
 Asynchronously execute a DELETE request with the given URL to be handled by the given response handler. More...
 
void delete (String url, AKHttpRequestData data, AKHttpRequestOptions options, AKHttpResponseHandler responseHandler)
 Asynchronously execute a DELETE request with the given URL, data, and options to be handled by the given response handler. More...
 
HttpResponse deleteSync (String url) throws IOException
 Synchronously execute a DELETE request with the given URL. More...
 
HttpResponse deleteSync (String url, AKHttpRequestData data, AKHttpRequestOptions options) throws IOException
 Synchronously execute a DELETE request with the given URL, data, and options. More...
 
void get (String url, AKHttpResponseHandler responseHandler)
 Asynchronously execute a GET request to the specified URL. More...
 
void get (String url, AKHttpRequestData data, AKHttpRequestOptions options, AKHttpResponseHandler responseHandler)
 Asynchronously execute a GET request with the specified URL, data, and options to be handled by the given response handler. More...
 
AKHttpRequestData getAgentRequestData ()
 Get the request data associated with every request made through this agent. More...
 
AKHttpRequestOptions getAgentRequestOptions ()
 Get the request options associated with every request made through this agent. More...
 
HttpResponse getSync (String url) throws IOException
 Synchronously execute a GET request with the given URL. More...
 
HttpResponse getSync (String url, AKHttpRequestData data, AKHttpRequestOptions options) throws IOException
 Synchronously execute a GET request with the given URL, data, and options. More...
 
void post (String url, AKHttpRequestData data, AKHttpResponseHandler responseHandler)
 Asynchronously execute a POST request with the given URL and request data to be handled by the given response handler. More...
 
void post (String url, AKHttpRequestData data, AKHttpRequestOptions options, AKHttpResponseHandler responseHandler)
 Asynchronously execute a POST request with the given URL, request data, and request options to be handled by the given response handler. More...
 
HttpResponse postSync (String url, AKHttpRequestData data) throws IOException
 Synchronously execute a POST request with the given URL and request data. More...
 
HttpResponse postSync (String url, AKHttpRequestData data, AKHttpRequestOptions options) throws IOException
 Synchronously execute a POST request with the given URL, request data, and request options. More...
 
void put (String url, AKHttpRequestData data, AKHttpResponseHandler responseHandler)
 Asynchronously execute a PUT request with the given URL and request data to be handled by the given response handler. More...
 
void put (String url, AKHttpRequestData data, AKHttpRequestOptions options, AKHttpResponseHandler responseHandler)
 Asynchronously execute a PUT request with the given URL, request data, and request options to be handled by the given response handler. More...
 
HttpResponse putSync (String url, AKHttpRequestData data) throws IOException
 Synchronously execute a PUT request with the given URL and request data. More...
 
HttpResponse putSync (String url, AKHttpRequestData data, AKHttpRequestOptions options) throws IOException
 Synchronously execute a PUT request with the given URL, request data, and request options. More...
 
void send (HttpUriRequest request, AKHttpResponseHandler responseHandler, AKHttpRequestOptions options)
 Asynchronously send a raw HTTP request to be executed by the given client and handled by the given response handler. More...
 
HttpResponse sendSync (HttpUriRequest request, AKHttpRequestOptions options) throws IOException
 Synchronously send a raw HTTP request to be executed by the given client. More...
 

Static Public Member Functions

static boolean isSuccessfulHttpResponse (HttpResponse response)
 Determine if this HttpResponse is successful. More...
 

Protected Member Functions

HttpClient getHttpClient (AKHttpRequestOptions options)
 Get the properly setup HTTP client to use to make a request, based on the AKHttpRequestOptions object. More...
 

Detailed Description

The AKHttpAgent class builds, executes, and manages HTTP requests.

Use the AKHttpRequestData class to pass any request data. On creation, the AKHttpAgent class defines an instance of the AKHttpRequestData class. Request data set on AKHttpAgent is then used by any AKServerAgent request method.

Alternatively, you can pass the request data to an individual request method, such as get() and put(). If you specify request data both at the class level and for a request method, the following occurs:

  • The request data from the class and from the method is combined. If there is a conflict, except for a request header, the setting from the method is used.
  • Request headers from the class and the method are merged to create a single set of request headers. If there is a conflict, the request header from the method is used.

Note: GET and DELETE requests ignore request body data.

See Also
AKHttpRequestData
AKHttpRequestOptions
Remote Data Access

Constructor & Destructor Documentation

com.verivo.akula.http.AKHttpAgent.AKHttpAgent ( )

Constructor.

Version
1.0

Member Function Documentation

void com.verivo.akula.http.AKHttpAgent.delete ( String  url,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a DELETE request with the given URL to be handled by the given response handler.

Parameters
urlThe URL of the HTTP request.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Exceptions
IllegalArgumentExceptionif url is invalid.
Version
1.0
void com.verivo.akula.http.AKHttpAgent.delete ( String  url,
AKHttpRequestData  data,
AKHttpRequestOptions  options,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a DELETE request with the given URL, data, and options to be handled by the given response handler.

Query parameters included in the data object are appended to the URL and any body data added to the data object is ignored.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
optionsAKHttpRequestOptions object representing any request options.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Exceptions
IllegalArgumentExceptionif url is invalid.
Version
1.0
HttpResponse com.verivo.akula.http.AKHttpAgent.deleteSync ( String  url) throws IOException

Synchronously execute a DELETE request with the given URL.

Parameters
urlThe URL of the HTTP request.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid.
Version
1.0
HttpResponse com.verivo.akula.http.AKHttpAgent.deleteSync ( String  url,
AKHttpRequestData  data,
AKHttpRequestOptions  options 
) throws IOException

Synchronously execute a DELETE request with the given URL, data, and options.

Query parameters included in the data object are appended to the URL and any body data added to the data object is ignored.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
optionsAKHttpRequestOptions object representing any request options.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid.
Version
1.0
void com.verivo.akula.http.AKHttpAgent.get ( String  url,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a GET request to the specified URL.

Parameters
urlThe URL of the HTTP request.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Exceptions
IllegalArgumentExceptionif url is invalid.
Version
1.0
void com.verivo.akula.http.AKHttpAgent.get ( String  url,
AKHttpRequestData  data,
AKHttpRequestOptions  options,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a GET request with the specified URL, data, and options to be handled by the given response handler.

Query parameters included in the data object are appended to the URL and any body data added to the data object is ignored.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
optionsAKHttpRequestOptions object representing any request options.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Exceptions
IllegalArgumentExceptionif url is invalid.
Version
1.0
AKHttpRequestData com.verivo.akula.http.AKHttpAgent.getAgentRequestData ( )

Get the request data associated with every request made through this agent.

Returns
AKHttpRequestData object.
Version
1.0
AKHttpRequestOptions com.verivo.akula.http.AKHttpAgent.getAgentRequestOptions ( )

Get the request options associated with every request made through this agent.

Returns
AKHttpRequestOptions object.
Version
1.0
HttpClient com.verivo.akula.http.AKHttpAgent.getHttpClient ( AKHttpRequestOptions  options)
protected

Get the properly setup HTTP client to use to make a request, based on the AKHttpRequestOptions object.

Parameters
optionsAKHttpRequestOptions object representing any request options.
Returns
Either the agent's HTTP client, the one specified in the options object, or a new default HTTP client with all options set.
Version
1.0
HttpResponse com.verivo.akula.http.AKHttpAgent.getSync ( String  url) throws IOException

Synchronously execute a GET request with the given URL.

Parameters
urlThe URL of the HTTP request.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid.
Version
1.0
HttpResponse com.verivo.akula.http.AKHttpAgent.getSync ( String  url,
AKHttpRequestData  data,
AKHttpRequestOptions  options 
) throws IOException

Synchronously execute a GET request with the given URL, data, and options.

Query parameters included in the data object are appended to the URL and any body data added to the data object is ignored.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
optionsAKHttpRequestOptions object representing any request options.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid
Version
1.0
static boolean com.verivo.akula.http.AKHttpAgent.isSuccessfulHttpResponse ( HttpResponse  response)
static

Determine if this HttpResponse is successful.

Override this method to change what is considered a successful HTTP response.

Parameters
responseThe HttpResponse object from an HTTP request.
Returns
true if the HTTP response was successful, based on status code and false otherwise.
Version
1.0
void com.verivo.akula.http.AKHttpAgent.post ( String  url,
AKHttpRequestData  data,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a POST request with the given URL and request data to be handled by the given response handler.

Query parameters included in the data object are appended to the URL and body data is added to the request body.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Exceptions
IllegalArgumentExceptionif url is invalid.
Version
1.0
void com.verivo.akula.http.AKHttpAgent.post ( String  url,
AKHttpRequestData  data,
AKHttpRequestOptions  options,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a POST request with the given URL, request data, and request options to be handled by the given response handler.

Query parameters included in the data object are appended to the URL and any body data added to the data object is added to the request body.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
optionsAKHttpRequestOptions object representing any request options.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Exceptions
IllegalArgumentExceptionif url is invalid.
Version
1.0
HttpResponse com.verivo.akula.http.AKHttpAgent.postSync ( String  url,
AKHttpRequestData  data 
) throws IOException

Synchronously execute a POST request with the given URL and request data.

Query parameters included in the data object are appended to the URL and body data is added to the request body.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid.
Version
1.0
HttpResponse com.verivo.akula.http.AKHttpAgent.postSync ( String  url,
AKHttpRequestData  data,
AKHttpRequestOptions  options 
) throws IOException

Synchronously execute a POST request with the given URL, request data, and request options.

Query parameters included in the data object are appended to the URL and any body data added to the data object is added to the request body.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
optionsAKHttpRequestOptions object representing any request options.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid.
Version
1.0
void com.verivo.akula.http.AKHttpAgent.put ( String  url,
AKHttpRequestData  data,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a PUT request with the given URL and request data to be handled by the given response handler.

Query parameters included in the data object are appended to the URL and body data is added to the request body.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Exceptions
IllegalArgumentExceptionif url is invalid.
Version
1.0
void com.verivo.akula.http.AKHttpAgent.put ( String  url,
AKHttpRequestData  data,
AKHttpRequestOptions  options,
AKHttpResponseHandler  responseHandler 
)

Asynchronously execute a PUT request with the given URL, request data, and request options to be handled by the given response handler.

Query parameters included in the data object are appended to the URL and any body data added to the data object is added to the request body.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
optionsAKHttpRequestOptions object representing any request options.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
Exceptions
IllegalArgumentExceptionif url is invalid.
Version
1.0
HttpResponse com.verivo.akula.http.AKHttpAgent.putSync ( String  url,
AKHttpRequestData  data 
) throws IOException

Synchronously execute a PUT request with the given URL and request data.

Query parameters included in the data object are appended to the URL and body data is added to the request body.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid.
Version
1.0
HttpResponse com.verivo.akula.http.AKHttpAgent.putSync ( String  url,
AKHttpRequestData  data,
AKHttpRequestOptions  options 
) throws IOException

Synchronously execute a PUT request with the given URL, request data, and request options.

Query parameters included in the data object are appended to the URL and any body data added to the data object is added to the request body.

Parameters
urlThe URL of the HTTP request.
dataAKHttpRequestData object representing the request data.
optionsAKHttpRequestOptions object representing any request options.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid.
Version
1.0
void com.verivo.akula.http.AKHttpAgent.send ( HttpUriRequest  request,
AKHttpResponseHandler  responseHandler,
AKHttpRequestOptions  options 
)

Asynchronously send a raw HTTP request to be executed by the given client and handled by the given response handler.

Parameters
requestHttpUriRequest object representing the request.
responseHandlerThe handler defining the onSuccess() handler method. called after a successful request, and the onFailure() handler method called when the request fails.
optionsAKHttpRequestOptions object containing the request options.
Version
1.0
HttpResponse com.verivo.akula.http.AKHttpAgent.sendSync ( HttpUriRequest  request,
AKHttpRequestOptions  options 
) throws IOException

Synchronously send a raw HTTP request to be executed by the given client.

Parameters
requestHttpUriRequest object representing the request.
optionsAKHttpRequestOptions object containing the request options.
Returns
An HttpResponse object.
Exceptions
IOException
ClientProtocolException
IllegalArgumentExceptionif url is invalid.
Version
1.0