Top Description Fields Constructors Methods
org.apache.http.impl.client

public abstract Class CloseableHttpClient

extends Object
implements HttpClient, Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable, org.apache.http.client.HttpClient
Known Direct Subclasses
org.apache.http.impl.client.InternalHttpClient, org.apache.http.impl.client.MinimalHttpClient, org.apache.http.impl.client.AbstractHttpClient
Annotations
@Contract
threading:SAFE
Imports
java.io.Closeable, .IOException, java.net.URI, org.apache.commons.logging.Log, .LogFactory, org.apache.http.HttpEntity, .HttpHost, .HttpRequest, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.client.ClientProtocolException, .HttpClient, .ResponseHandler, org.apache.http.client.methods.CloseableHttpResponse, .HttpUriRequest, org.apache.http.client.utils.URIUtils, org.apache.http.protocol.HttpContext, org.apache.http.util.Args, .EntityUtils

Base implementation of HttpClient that also implements Closeable.
Since
4.3

Field Summary

Modifier and TypeField and Description
private final Log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static HttpHost
protected abstract CloseableHttpResponse
doExecute(HttpHost target, HttpRequest request, HttpContext 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 HttpRequest
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.http.client.HttpClient.execute.

Executes HTTP request using the given context.
public CloseableHttpResponse
execute(final HttpUriRequest
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.http.client.HttpClient.execute.

Executes HTTP request using the given context.
public CloseableHttpResponse
execute(final HttpUriRequest
the request to execute
request
)

Implements org.apache.http.client.HttpClient.execute.

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 HttpRequest
the request to execute
request
)

Implements org.apache.http.client.HttpClient.execute.

Executes HTTP request using the default context.
public <T> T

Returns:

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

Implements org.apache.http.client.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 HttpUriRequest
the request to execute
request
,
final ResponseHandler<? extends T>
the response handler
responseHandler
,
final HttpContext
the context to use for the execution, or null to use the default context
context
)

Implements org.apache.http.client.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 HttpRequest
the request to execute
request
,
final ResponseHandler<? extends T>
the response handler
responseHandler
)

Implements org.apache.http.client.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 HttpRequest
the request to execute
request
,
final ResponseHandler<? extends T>
the response handler
responseHandler
,
final HttpContext
the context to use for the execution, or null to use the default context
context
)

Implements org.apache.http.client.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 final Log log

Constructor Detail

CloseableHttpClientback to summary
public CloseableHttpClient()

Method Detail

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

Implements org.apache.http.client.HttpClient.execute.

Doc from org.apache.http.client.HttpClient.execute.

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:HttpRequest

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
@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 CloseableHttpResponse execute(final HttpUriRequest request, final HttpContext context) throws IOException, ClientProtocolException

Implements org.apache.http.client.HttpClient.execute.

Doc from org.apache.http.client.HttpClient.execute.

Executes HTTP request using the given context.

Parameters
request:HttpUriRequest

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
@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 CloseableHttpResponse execute(final HttpUriRequest request) throws IOException, ClientProtocolException

Implements org.apache.http.client.HttpClient.execute.

Doc from org.apache.http.client.HttpClient.execute.

Executes HTTP request using the default context.

Parameters
request:HttpUriRequest

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
@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 CloseableHttpResponse execute(final HttpHost target, final HttpRequest request) throws IOException, ClientProtocolException

Implements org.apache.http.client.HttpClient.execute.

Doc from org.apache.http.client.HttpClient.execute.

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:HttpRequest

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
@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 HttpUriRequest request, final ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolException

Implements org.apache.http.client.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 ResponseHandlers from having to manage resource deallocation internally.

Parameters
request:HttpUriRequest

the request to execute

responseHandler:ResponseHandler<? 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 HttpUriRequest request, final ResponseHandler<? extends T> responseHandler, final HttpContext context) throws IOException, ClientProtocolException

Implements org.apache.http.client.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 ResponseHandlers from having to manage resource deallocation internally.

Parameters
request:HttpUriRequest

the request to execute

responseHandler:ResponseHandler<? extends T>

the response handler

context:HttpContext

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

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 HttpRequest request, final ResponseHandler<? extends T> responseHandler) throws IOException, ClientProtocolException

Implements org.apache.http.client.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 ResponseHandlers 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:HttpRequest

the request to execute

responseHandler:ResponseHandler<? 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 HttpRequest request, final ResponseHandler<? extends T> responseHandler, final HttpContext context) throws IOException, ClientProtocolException

Implements org.apache.http.client.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 ResponseHandlers 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:HttpRequest

the request to execute

responseHandler:ResponseHandler<? extends T>

the response handler

context:HttpContext

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

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