Top Description Fields Constructors Methods
org.apache.hc.client5.http.impl.classic

public abstract Class CloseableHttpClient

extends Object
implements HttpClient, ModalCloseable
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.io.ModalCloseable, java.io.Closeable, java.lang.AutoCloseable, org.apache.hc.client5.http.classic.HttpClient
Known Direct Subclasses
org.apache.hc.client5.http.impl.classic.InternalHttpClient, org.apache.hc.client5.http.impl.classic.MinimalHttpClient
Annotations
@Contract
threading:SAFE
Imports
java.io.IOException, org.apache.hc.client5.http.ClientProtocolException, org.apache.hc.client5.http.classic.HttpClient, org.apache.hc.client5.http.routing.RoutingSupport, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.ClassicHttpRequest, .ClassicHttpResponse, .HttpEntity, .HttpException, .HttpHost, org.apache.hc.core5.http.io.HttpClientResponseHandler, org.apache.hc.core5.http.io.entity.EntityUtils, org.apache.hc.core5.http.protocol.HttpContext, org.apache.hc.core5.io.ModalCloseable, org.apache.hc.core5.util.Args, org.slf4j.Logger, .LoggerFactory

Base implementation of HttpClient that also implements ModalCloseable.
Since
4.3

Field Summary

Modifier and TypeField and Description
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static HttpHost
protected abstract CloseableHttpResponse
public CloseableHttpResponse
execute(final HttpHost
the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.
target
,
final ClassicHttpRequest
the request to execute
request
,
final HttpContext
the context to use for the execution, or null to use the default context
context
)

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Deprecated It is strongly recommended to use execute methods with HttpClientResponseHandler such as execute(HttpHost, ClassicHttpRequest, HttpContext, HttpClientResponseHandler) in order to ensure automatic resource deallocation by the client.
Executes HTTP request using the given context.
public CloseableHttpResponse
execute(final ClassicHttpRequest
the request to execute
request
,
final HttpContext
the context to use for the execution, or null to use the default context
context
)

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Deprecated It is strongly recommended to use execute methods with HttpClientResponseHandler such as execute(ClassicHttpRequest, HttpContext, HttpClientResponseHandler) in order to ensure automatic resource deallocation by the client.
Executes HTTP request using the given context.
public CloseableHttpResponse
execute(final ClassicHttpRequest
the request to execute
request
)

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Deprecated It is strongly recommended to use execute methods with HttpClientResponseHandler such as execute(ClassicHttpRequest, HttpClientResponseHandler) in order to ensure automatic resource deallocation by the client.
Executes HTTP request using the default context.
public CloseableHttpResponse
execute(final HttpHost
the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.
target
,
final ClassicHttpRequest
the request to execute
request
)

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Deprecated It is strongly recommended to use execute methods with HttpClientResponseHandler such as execute(HttpHost, ClassicHttpRequest, HttpClientResponseHandler) in order to ensure automatic resource deallocation by the client.
Executes HTTP request using the default context.
public <T> T

Returns:

the response object as generated by the response handler.
execute
(final ClassicHttpRequest
the request to execute
request
,
final HttpClientResponseHandler<? extends T>
the response handler
responseHandler
)

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Executes a request using the default context and processes the response using the given response handler.
public <T> T

Returns:

the response object as generated by the response handler.
execute
(final ClassicHttpRequest
the request to execute
request
,
final HttpContext
the context to use for the execution, or null to use the default context
context
,
final HttpClientResponseHandler<? extends T>
the response handler
responseHandler
)

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Executes a request using the default context and processes the response using the given response handler.
public <T> T

Returns:

the response object as generated by the response handler.
execute
(final HttpHost
the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.
target
,
final ClassicHttpRequest
the request to execute
request
,
final HttpClientResponseHandler<? extends T>
the response handler
responseHandler
)

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Executes a request using the default context and processes the response using the given response handler.
public <T> T

Returns:

the response object as generated by the response handler.
execute
(final HttpHost
the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.
target
,
final ClassicHttpRequest
the request to execute
request
,
final HttpContext
the context to use for the execution, or null to use the default context
context
,
final HttpClientResponseHandler<? extends T>
the response handler
responseHandler
)

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Executes a request using the default context and processes the response using the given response handler.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Logger LOG

Constructor Detail

CloseableHttpClientback to summary
public CloseableHttpClient()

Method Detail

determineTargetback to summary
private static HttpHost determineTarget(final ClassicHttpRequest request) throws ClientProtocolException
doExecuteback to summary
protected abstract CloseableHttpResponse doExecute(HttpHost target, ClassicHttpRequest request, HttpContext context) throws IOException
executeback to summary
public CloseableHttpResponse execute(final HttpHost target, final ClassicHttpRequest request, final HttpContext context) throws IOException

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Doc from org.apache.hc.client5.http.classic.HttpClient.execute.

Deprecated

It is strongly recommended to use execute methods with HttpClientResponseHandler such as execute(HttpHost, ClassicHttpRequest, HttpContext, HttpClientResponseHandler) in order to ensure automatic resource deallocation by the client. For special cases one can still use executeOpen(HttpHost, ClassicHttpRequest, HttpContext) to keep the response object open after the request execution.

Executes HTTP request using the given context.

Parameters
target:HttpHost

the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.

request:ClassicHttpRequest

the request to execute

context:HttpContext

the context to use for the execution, or null to use the default context

Returns:CloseableHttpResponse

the response to the request. This is always a final response, never an intermediate response with an 1xx status code. Whether redirects or authentication challenges will be returned or handled automatically depends on the implementation and configuration of this client.

Annotations
@Deprecated
@Override
Exceptions
IOException:
in case of a problem or the connection was aborted
See Also
execute(HttpHost, ClassicHttpRequest, HttpContext, HttpClientResponseHandler), executeOpen(HttpHost, ClassicHttpRequest, HttpContext)
executeback to summary
public CloseableHttpResponse execute(final ClassicHttpRequest request, final HttpContext context) throws IOException

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Doc from org.apache.hc.client5.http.classic.HttpClient.execute.

Deprecated

It is strongly recommended to use execute methods with HttpClientResponseHandler such as execute(ClassicHttpRequest, HttpContext, HttpClientResponseHandler) in order to ensure automatic resource deallocation by the client. For special cases one can still use executeOpen(HttpHost, ClassicHttpRequest, HttpContext) to keep the response object open after the request execution.

Executes HTTP request using the given context.

Parameters
request:ClassicHttpRequest

the request to execute

context:HttpContext

the context to use for the execution, or null to use the default context

Returns:CloseableHttpResponse

the response to the request. This is always a final response, never an intermediate response with an 1xx status code. Whether redirects or authentication challenges will be returned or handled automatically depends on the implementation and configuration of this client.

Annotations
@Deprecated
@Override
Exceptions
IOException:
in case of a problem or the connection was aborted
See Also
execute(ClassicHttpRequest, HttpContext, HttpClientResponseHandler), executeOpen(HttpHost, ClassicHttpRequest, HttpContext)
executeback to summary
public CloseableHttpResponse execute(final ClassicHttpRequest request) throws IOException

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Doc from org.apache.hc.client5.http.classic.HttpClient.execute.

Deprecated

It is strongly recommended to use execute methods with HttpClientResponseHandler such as execute(ClassicHttpRequest, HttpClientResponseHandler) in order to ensure automatic resource deallocation by the client. For special cases one can still use executeOpen(HttpHost, ClassicHttpRequest, HttpContext) to keep the response object open after the request execution.

Executes HTTP request using the default context.

Parameters
request:ClassicHttpRequest

the request to execute

Returns:CloseableHttpResponse

the response to the request. This is always a final response, never an intermediate response with an 1xx status code. Whether redirects or authentication challenges will be returned or handled automatically depends on the implementation and configuration of this client.

Annotations
@Deprecated
@Override
Exceptions
IOException:
in case of a problem or the connection was aborted
See Also
execute(ClassicHttpRequest, HttpClientResponseHandler), executeOpen(HttpHost, ClassicHttpRequest, HttpContext)
executeback to summary
public CloseableHttpResponse execute(final HttpHost target, final ClassicHttpRequest request) throws IOException

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Doc from org.apache.hc.client5.http.classic.HttpClient.execute.

Deprecated

It is strongly recommended to use execute methods with HttpClientResponseHandler such as execute(HttpHost, ClassicHttpRequest, HttpClientResponseHandler) in order to ensure automatic resource deallocation by the client. For special cases one can still use executeOpen(HttpHost, ClassicHttpRequest, HttpContext) to keep the response object open after the request execution.

Executes HTTP request using the default context.

Parameters
target:HttpHost

the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.

request:ClassicHttpRequest

the request to execute

Returns:CloseableHttpResponse

the response to the request. This is always a final response, never an intermediate response with an 1xx status code. Whether redirects or authentication challenges will be returned or handled automatically depends on the implementation and configuration of this client.

Annotations
@Deprecated
@Override
Exceptions
IOException:
in case of a problem or the connection was aborted
See Also
execute(HttpHost, ClassicHttpRequest, HttpClientResponseHandler), executeOpen(HttpHost, ClassicHttpRequest, HttpContext)
executeback to summary
public <T> T execute(final ClassicHttpRequest request, final HttpClientResponseHandler<? extends T> responseHandler) throws IOException

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Executes a request using the default context and processes the response using the given response handler. The content entity associated with the response is fully consumed and the underlying connection is released back to the connection manager automatically in all cases relieving individual HttpClientResponseHandlers from having to manage resource deallocation internally.

Parameters
request:ClassicHttpRequest

the request to execute

responseHandler:HttpClientResponseHandler<? extends T>

the response handler

Returns:T

the response object as generated by the response handler.

Annotations
@Override
Exceptions
IOException:
in case of a problem or the connection was aborted
ClientProtocolException:
in case of an http protocol error
executeback to summary
public <T> T execute(final ClassicHttpRequest request, final HttpContext context, final HttpClientResponseHandler<? extends T> responseHandler) throws IOException

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Executes a request using the default context and processes the response using the given response handler. The content entity associated with the response is fully consumed and the underlying connection is released back to the connection manager automatically in all cases relieving individual HttpClientResponseHandlers from having to manage resource deallocation internally.

Parameters
request:ClassicHttpRequest

the request to execute

context:HttpContext

the context to use for the execution, or null to use the default context

responseHandler:HttpClientResponseHandler<? extends T>

the response handler

Returns:T

the response object as generated by the response handler.

Annotations
@Override
Exceptions
IOException:
in case of a problem or the connection was aborted
ClientProtocolException:
in case of an http protocol error
executeback to summary
public <T> T execute(final HttpHost target, final ClassicHttpRequest request, final HttpClientResponseHandler<? extends T> responseHandler) throws IOException

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Executes a request using the default context and processes the response using the given response handler. The content entity associated with the response is fully consumed and the underlying connection is released back to the connection manager automatically in all cases relieving individual HttpClientResponseHandlers from having to manage resource deallocation internally.

Parameters
target:HttpHost

the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.

request:ClassicHttpRequest

the request to execute

responseHandler:HttpClientResponseHandler<? extends T>

the response handler

Returns:T

the response object as generated by the response handler.

Annotations
@Override
Exceptions
IOException:
in case of a problem or the connection was aborted
ClientProtocolException:
in case of an http protocol error
executeback to summary
public <T> T execute(final HttpHost target, final ClassicHttpRequest request, final HttpContext context, final HttpClientResponseHandler<? extends T> responseHandler) throws IOException

Implements org.apache.hc.client5.http.classic.HttpClient.execute.

Executes a request using the default context and processes the response using the given response handler. The content entity associated with the response is fully consumed and the underlying connection is released back to the connection manager automatically in all cases relieving individual HttpClientResponseHandlers from having to manage resource deallocation internally.

Parameters
target:HttpHost

the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.

request:ClassicHttpRequest

the request to execute

context:HttpContext

the context to use for the execution, or null to use the default context

responseHandler:HttpClientResponseHandler<? extends T>

the response handler

Returns:T

the response object as generated by the response handler.

Annotations
@Override
Exceptions
IOException:
in case of a problem or the connection was aborted
ClientProtocolException:
in case of an http protocol error