Top Description Inners Fields Constructors Methods
org.apache.hc.core5.http.impl.io

public Class HttpRequestExecutor

extends Object
Class Inheritance
Annotations
@Contract
threading:IMMUTABLE
Imports
java.io.IOException, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.ClassicHttpRequest, .ClassicHttpResponse, .ConnectionReuseStrategy, .Header, .HeaderElements, .HttpEntity, .HttpException, .HttpHeaders, .HttpStatus, .HttpVersion, .ProtocolException, .ProtocolVersion, .UnsupportedHttpVersionException, org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy, .Http1StreamListener, org.apache.hc.core5.http.io.HttpClientConnection, .HttpResponseInformationCallback, org.apache.hc.core5.http.message.MessageSupport, .StatusLine, org.apache.hc.core5.http.protocol.HttpContext, .HttpCoreContext, .HttpProcessor, org.apache.hc.core5.io.Closer, org.apache.hc.core5.util.Args, .Timeout

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.

Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final ConnectionReuseStrategy
public static final Timeout
private final Http1StreamListener
private final Timeout

Constructor Summary

AccessConstructor and Description
public
HttpRequestExecutor(final Timeout waitForContinue, final ConnectionReuseStrategy connReuseStrategy, final Http1StreamListener streamListener)

Creates new instance of HttpRequestExecutor.

public
public

Method Summary

Modifier and TypeMethod and Description
public static HttpRequestExecutor.Builder
builder()

Create a new Builder.

public ClassicHttpResponse

Returns:

the response to the request.
execute
(final ClassicHttpRequest
the request to execute.
request
,
final HttpClientConnection
the connection over which to execute the request.
conn
,
final HttpResponseInformationCallback
callback to execute upon receipt of information status (1xx). May be null.
informationCallback
,
final HttpContext
the context
context
)

Sends the request and obtain a response.

public ClassicHttpResponse

Returns:

the response to the request.
execute
(final ClassicHttpRequest
the request to execute.
request
,
final HttpClientConnection
the connection over which to execute the request.
conn
,
final HttpContext
the context
context
)

Sends the request and obtain a response.

public boolean

Returns:

true is the connection can be kept-alive and re-used.
keepAlive
(final ClassicHttpRequest
current request object.
request
,
final ClassicHttpResponse
current response object.
response
,
final HttpClientConnection
actual connection.
connection
,
final HttpContext
current context.
context
)

Determines whether the connection can be kept alive and is safe to be re-used for subsequent message exchanges.

public void
postProcess(final ClassicHttpResponse
the response object to post-process
response
,
final HttpProcessor
the processor to use
processor
,
final HttpContext
the context for post-processing the response
context
)

Post-processes the given response using the given protocol processor and completes the process of request execution.

public void
preProcess(final ClassicHttpRequest
the request to prepare
request
,
final HttpProcessor
the processor to use
processor
,
final HttpContext
the context for sending the request
context
)

Pre-process the given request using the given protocol processor and initiates the process of request execution.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connReuseStrategyback to summary
private final ConnectionReuseStrategy connReuseStrategy
DEFAULT_WAIT_FOR_CONTINUEback to summary
public static final Timeout DEFAULT_WAIT_FOR_CONTINUE
streamListenerback to summary
private final Http1StreamListener streamListener
waitForContinueback to summary
private final Timeout waitForContinue

Constructor Detail

HttpRequestExecutorback to summary
public HttpRequestExecutor(final Timeout waitForContinue, final ConnectionReuseStrategy connReuseStrategy, final Http1StreamListener streamListener)

Creates new instance of HttpRequestExecutor.

Since
4.3
HttpRequestExecutorback to summary
public HttpRequestExecutor(final ConnectionReuseStrategy connReuseStrategy)
HttpRequestExecutorback to summary
public HttpRequestExecutor()

Method Detail

builderback to summary
public static HttpRequestExecutor.Builder builder()

Create a new Builder.

Since
5.2
executeback to summary
public ClassicHttpResponse execute(final ClassicHttpRequest request, final HttpClientConnection conn, final HttpResponseInformationCallback informationCallback, final HttpContext context) throws IOException, HttpException

Sends the request and obtain a response.

Parameters
request:ClassicHttpRequest

the request to execute.

conn:HttpClientConnection

the connection over which to execute the request.

informationCallback:HttpResponseInformationCallback

callback to execute upon receipt of information status (1xx). May be null.

context:HttpContext

the context

Returns:ClassicHttpResponse

the response to the request.

Exceptions
IOException:
in case of an I/O error.
HttpException:
in case of HTTP protocol violation or a processing problem.
executeback to summary
public ClassicHttpResponse execute(final ClassicHttpRequest request, final HttpClientConnection conn, final HttpContext context) throws IOException, HttpException

Sends the request and obtain a response.

Parameters
request:ClassicHttpRequest

the request to execute.

conn:HttpClientConnection

the connection over which to execute the request.

context:HttpContext

the context

Returns:ClassicHttpResponse

the response to the request.

Exceptions
IOException:
in case of an I/O error.
HttpException:
in case of HTTP protocol violation or a processing problem.
keepAliveback to summary
public boolean keepAlive(final ClassicHttpRequest request, final ClassicHttpResponse response, final HttpClientConnection connection, final HttpContext context) throws IOException

Determines whether the connection can be kept alive and is safe to be re-used for subsequent message exchanges.

Parameters
request:ClassicHttpRequest

current request object.

response:ClassicHttpResponse

current response object.

connection:HttpClientConnection

actual connection.

context:HttpContext

current context.

Returns:boolean

true is the connection can be kept-alive and re-used.

Exceptions
IOException:
in case of an I/O error.
postProcessback to summary
public void postProcess(final ClassicHttpResponse response, final HttpProcessor processor, final HttpContext context) throws HttpException, IOException

Post-processes the given response using the given protocol processor and completes the process of request execution.

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.

Parameters
response:ClassicHttpResponse

the response object to post-process

processor:HttpProcessor

the processor to use

context:HttpContext

the context for post-processing the response

Exceptions
HttpException:
in case of HTTP protocol violation or a processing problem.
IOException:
in case of an I/O error.
preProcessback to summary
public void preProcess(final ClassicHttpRequest request, final HttpProcessor processor, final HttpContext context) throws HttpException, IOException

Pre-process the given request using the given protocol processor and initiates the process of request execution.

Parameters
request:ClassicHttpRequest

the request to prepare

processor:HttpProcessor

the processor to use

context:HttpContext

the context for sending the request

Exceptions
HttpException:
in case of HTTP protocol violation or a processing problem.
IOException:
in case of an I/O error.
org.apache.hc.core5.http.impl.io back to summary

public final Class HttpRequestExecutor.Builder

extends Object
Class Inheritance

Builder for HttpRequestExecutor.
Since
5.2

Field Summary

Modifier and TypeField and Description
private ConnectionReuseStrategy
private Http1StreamListener
private Timeout

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public HttpRequestExecutor
build()

Create a new HTTP Request Executor.

public HttpRequestExecutor.Builder
public HttpRequestExecutor.Builder
public HttpRequestExecutor.Builder
withWaitForContinue(final Timeout waitForContinue)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connReuseStrategyback to summary
private ConnectionReuseStrategy connReuseStrategy
streamListenerback to summary
private Http1StreamListener streamListener
waitForContinueback to summary
private Timeout waitForContinue

Constructor Detail

Builderback to summary
private Builder()

Method Detail

buildback to summary
public HttpRequestExecutor build()

Create a new HTTP Request Executor.

Since
5.2
withConnectionReuseStrategyback to summary
public HttpRequestExecutor.Builder withConnectionReuseStrategy(final ConnectionReuseStrategy connReuseStrategy)
withHttp1StreamListenerback to summary
public HttpRequestExecutor.Builder withHttp1StreamListener(final Http1StreamListener streamListener)
withWaitForContinueback to summary
public HttpRequestExecutor.Builder withWaitForContinue(final Timeout waitForContinue)