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

public Class DecompressingHttpClient

extends Object
implements HttpClient
Class Inheritance
All Implemented Interfaces
org.apache.http.client.HttpClient
Annotations
@Deprecated
Imports
java.io.IOException, java.net.URI, org.apache.http.HttpEntity, .HttpEntityEnclosingRequest, .HttpException, .HttpHost, .HttpRequest, .HttpRequestInterceptor, .HttpResponse, .HttpResponseInterceptor, org.apache.http.client.ClientProtocolException, .HttpClient, .ResponseHandler, org.apache.http.client.methods.HttpUriRequest, org.apache.http.client.protocol.RequestAcceptEncoding, .ResponseContentEncoding, org.apache.http.client.utils.URIUtils, org.apache.http.conn.ClientConnectionManager, org.apache.http.params.HttpParams, org.apache.http.protocol.BasicHttpContext, .HttpContext, org.apache.http.util.EntityUtils

Deprecated

(4.3) use HttpClientBuilder

Decorator adding support for compressed responses. This class sets the Accept-Encoding header on requests to indicate support for the gzip and deflate compression schemes; it then checks the Content-Encoding header on the response to uncompress any compressed response bodies. The java.io.InputStream of the entity will contain the uncompressed content.

N.B. Any upstream clients of this class need to be aware that this effectively obscures visibility into the length of a server response body, since the Content-Length header will correspond to the compressed entity length received from the server, but the content length experienced by reading the response body may be different (hopefully higher!).

That said, this decorator is compatible with the CachingHttpClient in that the two decorators can be added in either order and still have cacheable responses be cached.

Since
4.2

Field Summary

Modifier and TypeField and Description
private final HttpRequestInterceptor
private final HttpClient
private final HttpResponseInterceptor

Constructor Summary

AccessConstructor and Description
public
DecompressingHttpClient()

Constructs a decorator to ask for and handle compressed entities on the fly.

public
DecompressingHttpClient(final HttpClient
the HttpClient to use for actually issuing requests
backend
)

Constructs a decorator to ask for and handle compressed entities on the fly.

pack-priv
DecompressingHttpClient(final HttpClient backend, final HttpRequestInterceptor requestInterceptor, final HttpResponseInterceptor responseInterceptor)

Method Summary

Modifier and TypeMethod and Description
public HttpResponse
execute(final HttpUriRequest
the request to execute
request
)

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

Executes HTTP request using the default context.
public HttpResponse
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 HttpResponse
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 HttpResponse
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 <T> T
execute(final HttpUriRequest
the request to execute
request
,
final ResponseHandler<? extends T>
the response handler
responseHandler
)

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

Executes HTTP request using the default context and processes the response using the given response handler.
public <T> T
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 HTTP request using the given context and processes the response using the given response handler.
public <T> T
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 HTTP request to the target using the default context and processes the response using the given response handler.
public <T> T
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 HTTP request to the target using the given context and processes the response using the given response handler.
public ClientConnectionManager
getConnectionManager()

Implements org.apache.http.client.HttpClient.getConnectionManager.

Deprecated as a consequence of ClientConnectionManager being deprecated.
Obtains the connection manager used by this client.
public HttpClient

Returns:

the HttpClient to issue request
getHttpClient
()

Gets the HttpClient to issue request.

pack-priv HttpHost
getHttpHost(final HttpUriRequest request)

public HttpParams
getParams()

Implements org.apache.http.client.HttpClient.getParams.

Deprecated as a consequence of HttpParams being deprecated.
Obtains the parameters for this client.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

acceptEncodingInterceptorback to summary
private final HttpRequestInterceptor acceptEncodingInterceptor
backendback to summary
private final HttpClient backend
contentEncodingInterceptorback to summary
private final HttpResponseInterceptor contentEncodingInterceptor

Constructor Detail

DecompressingHttpClientback to summary
public DecompressingHttpClient()

Constructs a decorator to ask for and handle compressed entities on the fly.

DecompressingHttpClientback to summary
public DecompressingHttpClient(final HttpClient backend)

Constructs a decorator to ask for and handle compressed entities on the fly.

Parameters
backend:HttpClient

the HttpClient to use for actually issuing requests

DecompressingHttpClientback to summary
pack-priv DecompressingHttpClient(final HttpClient backend, final HttpRequestInterceptor requestInterceptor, final HttpResponseInterceptor responseInterceptor)

Method Detail

executeback to summary
public HttpResponse 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: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.

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

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

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

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.

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

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.

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.

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

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.

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.

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

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.

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.

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

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.

Annotations
@Override
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()

Implements org.apache.http.client.HttpClient.getConnectionManager.

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

Deprecated

as a consequence of ClientConnectionManager being deprecated. See corresponding docs for further information.

Obtains the connection manager used by this client.

Returns:ClientConnectionManager

the connection manager

Annotations
@Override
getHttpClientback to summary
public HttpClient getHttpClient()

Gets the HttpClient to issue request.

Returns:HttpClient

the HttpClient to issue request

getHttpHostback to summary
pack-priv HttpHost getHttpHost(final HttpUriRequest request)
getParamsback to summary
public HttpParams getParams()

Implements org.apache.http.client.HttpClient.getParams.

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

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

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
@Override