Sends HTTP requests and receives the responses. More...
Takes care of request preprocessing and response postprocessing by the respective interceptors.
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... | |
|
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.
request | the request, to obtain the executed method |
response | the response, to obtain the status code |
HttpResponse execute | ( | final HttpRequest | request, |
final HttpClientConnection | conn, | ||
final HttpContext | context | ||
) | throws IOException, HttpException |
request | the request to send. It will be preprocessed. |
conn | the open connection over which to send |
context | HTTP contect |
HttpException | in case of a protocol or processing problem |
IOException | in case of an I/O problem |
void preProcess | ( | final HttpRequest | request, |
final HttpProcessor | processor, | ||
final HttpContext | context | ||
) | throws HttpException, IOException |
request | the request to prepare |
processor | the processor to use |
context | the context for sending the request |
HttpException | in case of a protocol or processing problem |
IOException | in case of an I/O problem |
|
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.
request | the request to send, already preprocessed |
conn | the connection over which to send the request, already established |
context | the context for sending the request |
null
if the expect-continue handshake is not usedHttpException | in case of a protocol or processing problem |
IOException | in case of an I/O problem |
|
protected |
This method will automatically ignore intermediate responses with status code 1xx.
request | the request for which to obtain the response |
conn | the connection over which the request was sent |
context | the context for receiving the response |
HttpException | in case of a protocol or processing problem |
IOException | in case of an I/O problem |
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.
response | the response object to finish |
processor | the processor to use |
context | the context for post-processing the response |
HttpException | in case of a protocol or processing problem |
IOException | in case of an I/O problem |