public class ApacheHttpClient extends Client
Client
that utilizes the Apache HTTP client to send and receive
HTTP request and responses.
If an ApacheHttpClientHandler
is not explicitly passed as a
constructor or method parameter then by default an instance is created with
an HttpClient
constructed with a MultiThreadedHttpConnectionManager
instance.
The following properties are only supported at construction of this class:
ApacheHttpClientConfig.PROPERTY_PREEMPTIVE_AUTHENTICATION
and
ClientConfig.PROPERTY_CONNECT_TIMEOUT
.
By default a request entity is buffered and repeatable such that authorization may be performed automatically in response to a 401 response.
If the property ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE
size
is set to a value greater than 0 then chunked encoding will be enabled
and the request entity (if present) will not be buffered and is not
repeatable. For authorization to work in such scenarios the property
ApacheHttpClientConfig.PROPERTY_PREEMPTIVE_AUTHENTICATION
must
be set to true.
If a response entity is obtained that is an instance of
Closeable
then the instance MUST be closed after processing the entity to release
connection-based resources.
If a ClientResponse
is obtained and an
entity is not read from the response then
ClientResponse.close()
MUST be called
after processing the response to release connection-based resources.
Constructor and Description |
---|
ApacheHttpClient()
Create a new client instance.
|
ApacheHttpClient(ApacheHttpClientHandler root)
Create a new client instance.
|
ApacheHttpClient(ApacheHttpClientHandler root,
ClientConfig config,
IoCComponentProviderFactory provider)
Deprecated.
the config parameter is no longer utilized and instead
the config obtained from the
ApacheHttpClientHandler.getConfig()
is utilized instead. |
ApacheHttpClient(ApacheHttpClientHandler root,
IoCComponentProviderFactory provider)
Create a new instance with a client configuration and a
component provider.
|
Modifier and Type | Method and Description |
---|---|
static ApacheHttpClient |
create()
Create a default client.
|
static ApacheHttpClient |
create(ClientConfig cc)
Create a default client with client configuration.
|
static ApacheHttpClient |
create(ClientConfig cc,
IoCComponentProviderFactory provider)
Create a default client with client configuration and component provider.
|
ApacheHttpClientHandler |
getClientHandler()
Get the Apache HTTP client handler.
|
asyncResource, asyncResource, asyncView, asyncView, asyncView, asyncView, asyncViewResource, asyncViewResource, destroy, finalize, getExecutorService, getMessageBodyWorkers, getProperties, getProviders, getViewProxy, handle, inject, resource, resource, setChunkedEncodingSize, setConnectTimeout, setExecutorService, setFollowRedirects, setReadTimeout, view, view, view, view, view, view, viewResource, viewResource
addFilter, getHeadHandler, isFilterPreset, removeAllFilters, removeFilter
public ApacheHttpClient()
public ApacheHttpClient(ApacheHttpClientHandler root)
root
- the root client handler for dispatching a request and
returning a response.@Deprecated public ApacheHttpClient(ApacheHttpClientHandler root, ClientConfig config, IoCComponentProviderFactory provider)
ApacheHttpClientHandler.getConfig()
is utilized instead.root
- the root client handler for dispatching a request and
returning a response.config
- the client configuration.provider
- the IoC component provider factory.public ApacheHttpClient(ApacheHttpClientHandler root, IoCComponentProviderFactory provider)
root
- the root client handler for dispatching a request and
returning a response.provider
- the IoC component provider factory.public ApacheHttpClientHandler getClientHandler()
public static ApacheHttpClient create()
public static ApacheHttpClient create(ClientConfig cc)
cc
- the client configuration.public static ApacheHttpClient create(ClientConfig cc, IoCComponentProviderFactory provider)
cc
- the client configuration.provider
- the IoC component provider factory.Copyright © 2013 Oracle Corporation. All rights reserved.