• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
HttpRequestExecutor Class Reference

Sends HTTP requests and receives the responses. More...

Description

Takes care of request preprocessing and response postprocessing by the respective interceptors.

Author
Oleg Kalnichevski
Version
Revision
576073
Since
4.0

Notice

The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.

/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Public Member Functions

 HttpRequestExecutor ()
 Create a new request executor.
 
HttpResponse execute (final HttpRequest request, final HttpClientConnection conn, final HttpContext context) throws IOException, HttpException
 Synchronously send a request and obtain the response. More...
 
void preProcess (final HttpRequest request, final HttpProcessor processor, final HttpContext context) throws HttpException, IOException
 Prepare a request for sending. More...
 
void postProcess (final HttpResponse response, final HttpProcessor processor, final HttpContext context) throws HttpException, IOException
 Finish a response. More...
 

Protected Member Functions

boolean canResponseHaveBody (final HttpRequest request, final HttpResponse response)
 Decide whether a response comes with an entity. More...
 
HttpResponse doSendRequest (final HttpRequest request, final HttpClientConnection conn, final HttpContext context) throws IOException, HttpException
 Send a request over a connection. More...
 
HttpResponse doReceiveResponse (final HttpRequest request, final HttpClientConnection conn, final HttpContext context) throws HttpException, IOException
 Wait for and receive a response. More...
 

Member Function Documentation

◆ canResponseHaveBody()

boolean canResponseHaveBody ( final HttpRequest  request,
final HttpResponse  response 
)
protected

The implementation in this class is based on RFC 2616. Unknown methods and response codes are supposed to indicate responses with an entity.
Derived executors can override this method to handle methods and response codes not specified in RFC 2616.

Parameters
requestthe request, to obtain the executed method
responsethe response, to obtain the status code

◆ execute()

HttpResponse execute ( final HttpRequest  request,
final HttpClientConnection  conn,
final HttpContext  context 
) throws IOException, HttpException
Parameters
requestthe request to send. It will be preprocessed.
connthe open connection over which to send
contextHTTP contect
Returns
the response to the request, postprocessed
Exceptions
HttpExceptionin case of a protocol or processing problem
IOExceptionin case of an I/O problem

◆ preProcess()

void preProcess ( final HttpRequest  request,
final HttpProcessor  processor,
final HttpContext  context 
) throws HttpException, IOException
Parameters
requestthe request to prepare
processorthe processor to use
contextthe context for sending the request
Exceptions
HttpExceptionin case of a protocol or processing problem
IOExceptionin case of an I/O problem

◆ doSendRequest()

HttpResponse doSendRequest ( final HttpRequest  request,
final HttpClientConnection  conn,
final HttpContext  context 
) throws IOException, HttpException
protected

This method also handles the expect-continue handshake if necessary. If it does not have to handle an expect-continue handshake, it will not use the connection for reading or anything else that depends on data coming in over the connection.

Parameters
requestthe request to send, already preprocessed
connthe connection over which to send the request, already established
contextthe context for sending the request
Returns
a terminal response received as part of an expect-continue handshake, or null if the expect-continue handshake is not used
Exceptions
HttpExceptionin case of a protocol or processing problem
IOExceptionin case of an I/O problem

◆ doReceiveResponse()

HttpResponse doReceiveResponse ( final HttpRequest  request,
final HttpClientConnection  conn,
final HttpContext  context 
) throws HttpException, IOException
protected

This method will automatically ignore intermediate responses with status code 1xx.

Parameters
requestthe request for which to obtain the response
connthe connection over which the request was sent
contextthe context for receiving the response
Returns
the final response, not yet post-processed
Exceptions
HttpExceptionin case of a protocol or processing problem
IOExceptionin case of an I/O problem

◆ postProcess()

void postProcess ( final HttpResponse  response,
final HttpProcessor  processor,
final HttpContext  context 
) throws HttpException, IOException

This includes post-processing of the response object. It does not read the response entity, if any. It does not allow for immediate re-use of the connection over which the response is coming in.

Parameters
responsethe response object to finish
processorthe processor to use
contextthe context for post-processing the response
Exceptions
HttpExceptionin case of a protocol or processing problem
IOExceptionin case of an I/O problem