@Contract(threading=IMMUTABLE) public class HttpRequestExecutor extends Object
HttpRequestExecutor
is a client side HTTP protocol handler based
on the blocking (classic) I/O model.
HttpRequestExecutor
relies on HttpProcessor
to generate
mandatory protocol headers for all outgoing messages and apply common,
cross-cutting message transformations to all incoming and outgoing messages.
Application specific processing can be implemented outside
HttpRequestExecutor
once the request has been executed and
a response has been received.
Modifier and Type | Field and Description |
---|---|
static Timeout |
DEFAULT_WAIT_FOR_CONTINUE |
Constructor and Description |
---|
HttpRequestExecutor() |
HttpRequestExecutor(ConnectionReuseStrategy connReuseStrategy) |
HttpRequestExecutor(Timeout waitForContinue,
ConnectionReuseStrategy connReuseStrategy,
Http1StreamListener streamListener)
Creates new instance of HttpRequestExecutor.
|
Modifier and Type | Method and Description |
---|---|
ClassicHttpResponse |
execute(ClassicHttpRequest request,
HttpClientConnection conn,
HttpContext context)
Sends the request and obtain a response.
|
ClassicHttpResponse |
execute(ClassicHttpRequest request,
HttpClientConnection conn,
HttpResponseInformationCallback informationCallback,
HttpContext context)
Sends the request and obtain a response.
|
boolean |
keepAlive(ClassicHttpRequest request,
ClassicHttpResponse response,
HttpClientConnection connection,
HttpContext context)
Determines whether the connection can be kept alive and is safe to be re-used for subsequent message exchanges.
|
void |
postProcess(ClassicHttpResponse response,
HttpProcessor processor,
HttpContext context)
Post-processes the given response using the given protocol processor and
completes the process of request execution.
|
void |
preProcess(ClassicHttpRequest request,
HttpProcessor processor,
HttpContext context)
Pre-process the given request using the given protocol processor and
initiates the process of request execution.
|
public static final Timeout DEFAULT_WAIT_FOR_CONTINUE
public HttpRequestExecutor(Timeout waitForContinue, ConnectionReuseStrategy connReuseStrategy, Http1StreamListener streamListener)
public HttpRequestExecutor(ConnectionReuseStrategy connReuseStrategy)
public HttpRequestExecutor()
public ClassicHttpResponse execute(ClassicHttpRequest request, HttpClientConnection conn, HttpResponseInformationCallback informationCallback, HttpContext context) throws IOException, HttpException
request
- the request to execute.conn
- the connection over which to execute the request.informationCallback
- callback to execute upon receipt of information status (1xx).
May be null.context
- the contextIOException
- in case of an I/O error.HttpException
- in case of HTTP protocol violation or a processing
problem.public ClassicHttpResponse execute(ClassicHttpRequest request, HttpClientConnection conn, HttpContext context) throws IOException, HttpException
request
- the request to execute.conn
- the connection over which to execute the request.context
- the contextIOException
- in case of an I/O error.HttpException
- in case of HTTP protocol violation or a processing
problem.public void preProcess(ClassicHttpRequest request, HttpProcessor processor, HttpContext context) throws HttpException, IOException
request
- the request to prepareprocessor
- the processor to usecontext
- the context for sending the requestIOException
- in case of an I/O error.HttpException
- in case of HTTP protocol violation or a processing
problem.public void postProcess(ClassicHttpResponse response, HttpProcessor processor, HttpContext context) throws HttpException, IOException
This method does not read the response entity, if any. The connection over which content of the response entity is being streamed from cannot be reused until the response entity has been fully consumed.
response
- the response object to post-processprocessor
- the processor to usecontext
- the context for post-processing the responseIOException
- in case of an I/O error.HttpException
- in case of HTTP protocol violation or a processing
problem.public boolean keepAlive(ClassicHttpRequest request, ClassicHttpResponse response, HttpClientConnection connection, HttpContext context) throws IOException
request
- current request object.response
- current response object.connection
- actual connection.context
- current context.true
is the connection can be kept-alive and re-used.IOException
- in case of an I/O error.Copyright © 2005–2022 The Apache Software Foundation. All rights reserved.