java.lang.Object
org.apache.http.protocol.AbstractHttpProcessor
org.apache.http.protocol.HttpRequestExecutor
- public class HttpRequestExecutor
- extends AbstractHttpProcessor
Sends HTTP requests and receives the responses.
Takes care of request preprocessing and response postprocessing
by the respective interceptors.
- Since:
- 4.0
- Version:
- $Revision: 385867 $
|
Method Summary |
protected boolean |
canResponseHaveBody(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response)
Decide whether a response comes with an entity. |
protected void |
doEstablishConnection(org.apache.http.HttpClientConnection conn,
org.apache.http.HttpHost target,
org.apache.http.params.HttpParams params)
Establish a connection with the target host. |
protected void |
doFinishResponse(org.apache.http.HttpResponse response,
HttpContext context)
Finish a response. |
protected void |
doPrepareRequest(org.apache.http.HttpRequest request,
HttpContext context)
Prepare a request for sending. |
protected org.apache.http.HttpResponse |
doReceiveResponse(org.apache.http.HttpRequest request,
org.apache.http.HttpClientConnection conn,
HttpContext context)
Wait for and receive a response. |
protected org.apache.http.HttpResponse |
doSendRequest(org.apache.http.HttpRequest request,
org.apache.http.HttpClientConnection conn,
HttpContext context)
Send a request over a connection. |
org.apache.http.HttpResponse |
execute(org.apache.http.HttpRequest request,
org.apache.http.HttpClientConnection conn)
Synchronously send a request and obtain the response. |
HttpContext |
getContext()
Obtain the default context information. |
org.apache.http.params.HttpParams |
getParams()
Obtain the parameters for executing requests. |
HttpRequestRetryHandler |
getRetryHandler()
Obtain the retry handler. |
void |
setParams(org.apache.http.params.HttpParams params)
Set new parameters for executing requests. |
void |
setRetryHandler(HttpRequestRetryHandler retryhandler)
Set the retry handler. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WAIT_FOR_CONTINUE_MS
protected static final int WAIT_FOR_CONTINUE_MS
- See Also:
- Constant Field Values
defaultContext
protected final HttpContext defaultContext
- The context holding the default context information.
params
private org.apache.http.params.HttpParams params
retryhandler
private HttpRequestRetryHandler retryhandler
HttpRequestExecutor
public HttpRequestExecutor(HttpContext parentContext)
- Create a new request executor with default context information.
The attributes in the argument context will be made available
in the context used for executing a request.
HttpRequestExecutor
public HttpRequestExecutor()
- Create a new request executor.
getContext
public final HttpContext getContext()
- Obtain the default context information.
This is not necessarily the same object passed to the constructor,
but the default context information will be available here.
getParams
public final org.apache.http.params.HttpParams getParams()
- Obtain the parameters for executing requests.
setParams
public final void setParams(org.apache.http.params.HttpParams params)
- Set new parameters for executing requests.
getRetryHandler
public final HttpRequestRetryHandler getRetryHandler()
- Obtain the retry handler.
setRetryHandler
public final void setRetryHandler(HttpRequestRetryHandler retryhandler)
- Set the retry handler.
canResponseHaveBody
protected boolean canResponseHaveBody(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response)
- Decide whether a response comes with an entity.
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.
execute
public org.apache.http.HttpResponse execute(org.apache.http.HttpRequest request,
org.apache.http.HttpClientConnection conn)
throws java.io.IOException,
org.apache.http.HttpException
- Synchronously send a request and obtain the response.
doPrepareRequest
protected void doPrepareRequest(org.apache.http.HttpRequest request,
HttpContext context)
throws org.apache.http.HttpException,
java.io.IOException
- Prepare a request for sending.
doEstablishConnection
protected void doEstablishConnection(org.apache.http.HttpClientConnection conn,
org.apache.http.HttpHost target,
org.apache.http.params.HttpParams params)
throws org.apache.http.HttpException,
java.io.IOException
- Establish a connection with the target host.
doSendRequest
protected org.apache.http.HttpResponse doSendRequest(org.apache.http.HttpRequest request,
org.apache.http.HttpClientConnection conn,
HttpContext context)
throws java.io.IOException,
org.apache.http.HttpException
- Send a request over a connection.
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.
doReceiveResponse
protected org.apache.http.HttpResponse doReceiveResponse(org.apache.http.HttpRequest request,
org.apache.http.HttpClientConnection conn,
HttpContext context)
throws org.apache.http.HttpException,
java.io.IOException
- Wait for and receive a response.
This method will automatically ignore intermediate responses
with status code 1xx.
doFinishResponse
protected void doFinishResponse(org.apache.http.HttpResponse response,
HttpContext context)
throws org.apache.http.HttpException,
java.io.IOException
- Finish a response.
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.