Top Description Methods
org.apache.http.client

public Interface HttpClient

Known Direct Implementers
org.apache.http.impl.client.AutoRetryHttpClient, org.apache.http.impl.client.CloseableHttpClient, org.apache.http.impl.client.DecompressingHttpClient
Annotations
@SuppressWarnings:deprecation
Imports
org.apache.http.HttpHost, .HttpRequest, .HttpResponse, org.apache.http.client.methods.HttpUriRequest, org.apache.http.conn.ClientConnectionManager, org.apache.http.params.HttpParams, org.apache.http.protocol.HttpContext, java.io.IOException

This interface represents only the most basic contract for HTTP request execution. It imposes no restrictions or particular details on the request execution process and leaves the specifics of state management, authentication and redirect handling up to individual implementations.
Since
4.0

Method Summary

Modifier and TypeMethod and Description
public HttpResponse

Returns:

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.
execute
(HttpUriRequest
the request to execute
request
)

Executes HTTP request using the default context.

public HttpResponse

Returns:

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.
execute
(HttpUriRequest
the request to execute
request
,
HttpContext
the context to use for the execution, or null to use the default context
context
)

Executes HTTP request using the given context.

public HttpResponse

Returns:

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

Executes HTTP request using the default context.

public HttpResponse

Returns:

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.
execute
(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
,
HttpRequest
the request to execute
request
,
HttpContext
the context to use for the execution, or null to use the default context
context
)

Executes HTTP request using the given context.

public <T> T

Returns:

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

Executes HTTP 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
(HttpUriRequest
the request to execute
request
,
ResponseHandler<? extends T>
the response handler
responseHandler
,
HttpContext
the context to use for the execution, or null to use the default context
context
)

Executes HTTP request using the given context and processes the response using the given response handler.

public <T> T

Returns:

the response object as generated by the response handler.
execute
(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
,
HttpRequest
the request to execute
request
,
ResponseHandler<? extends T>
the response handler
responseHandler
)

Executes HTTP request to the target 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
(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
,
HttpRequest
the request to execute
request
,
ResponseHandler<? extends T>
the response handler
responseHandler
,
HttpContext
the context to use for the execution, or null to use the default context
context
)

Executes HTTP request to the target using the given context and processes the response using the given response handler.

public ClientConnectionManager

Returns:

the connection manager
getConnectionManager
()

Obtains the connection manager used by this client.
public HttpParams

Returns:

the default parameters
getParams
()

Obtains the parameters for this client.

Method Detail

executeback to summary
public HttpResponse execute(HttpUriRequest request) throws IOException, ClientProtocolException

Executes HTTP request using the default context.

Parameters
request:HttpUriRequest

the request to execute

Returns:HttpResponse

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.

Exceptions
IOException:
in case of a problem or the connection was aborted
ClientProtocolException:
in case of an http protocol error
executeback to summary
public HttpResponse execute(HttpUriRequest request, HttpContext context) throws IOException, ClientProtocolException

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

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.

Exceptions
IOException:
in case of a problem or the connection was aborted
ClientProtocolException:
in case of an http protocol error
executeback to summary
public HttpResponse execute(HttpHost target, HttpRequest request) throws IOException, ClientProtocolException

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

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.

Exceptions
IOException:
in case of a problem or the connection was aborted
ClientProtocolException:
in case of an http protocol error
executeback to summary
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException

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

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.

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

Executes HTTP request using the default context and processes the response using the given response handler.

Implementing classes are required to ensure that 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.

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

Executes HTTP request using the given context and processes the response using the given response handler.

Implementing classes are required to ensure that 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.

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

Executes HTTP request to the target using the default context and processes the response using the given response handler.

Implementing classes are required to ensure that 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.

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

Executes HTTP request to the target using the given context and processes the response using the given response handler.

Implementing classes are required to ensure that 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.

Exceptions
IOException:
in case of a problem or the connection was aborted
ClientProtocolException:
in case of an http protocol error
getConnectionManagerback to summary
public ClientConnectionManager getConnectionManager()

Obtains the connection manager used by this client.

Returns:ClientConnectionManager

the connection manager

Annotations
@Deprecated
getParamsback to summary
public HttpParams getParams()

Obtains the parameters for this client. These parameters will become defaults for all requests being executed with this client, and for the parameters of dependent objects in this client.

Returns:HttpParams

the default parameters

Annotations
@Deprecated