public class ApacheConnector extends Object implements Connector
Connector that utilizes the Apache HTTP Client to send and receive
HTTP request and responses.
The following properties are only supported at construction of this class:
ApacheClientProperties.CONNECTION_MANAGERApacheClientProperties.REQUEST_CONFIG (or ApacheClientProperties.HTTP_PARAMS)ApacheClientProperties.CREDENTIALS_PROVIDERApacheClientProperties.DISABLE_COOKIESClientProperties.PROXY_URI (or ApacheClientProperties.PROXY_URI)ClientProperties.PROXY_USERNAME (or ApacheClientProperties.PROXY_USERNAME)ClientProperties.PROXY_PASSWORD (or ApacheClientProperties.PROXY_PASSWORD)ClientProperties.REQUEST_ENTITY_PROCESSING - default value is RequestEntityProcessing.CHUNKEDApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATIONApacheClientProperties.SSL_CONFIG
This connector uses chunked encoding as a default setting. This can
be overridden by the ClientProperties.REQUEST_ENTITY_PROCESSING. By default the
ClientProperties.CHUNKED_ENCODING_SIZE property is only supported by using default connection manager. If custom
connection manager needs to be used then chunked encoding size can be set by providing a custom
HttpClientConnection (via custom ManagedHttpClientConnectionFactory)
and overriding createOutputStream method.
Using of authorization is dependent on the chunk encoding setting. If the entity
buffering is enabled, the entity is buffered and authorization can be performed
automatically in response to a 401 by sending the request again. When entity buffering
is disabled (chunked encoding is used) then the property
ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION must
be set to true.
If a ClientResponse is obtained and an
entity is not read from the response then
InboundMessageContext.close() MUST be called
after processing the response to release connection-based resources.
Client operations are thread safe, the HTTP connection may be shared between different threads.
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.
The following methods are currently supported: HEAD, GET, POST, PUT, DELETE, OPTIONS, PATCH and TRACE.
ApacheClientProperties.CONNECTION_MANAGER| Modifier and Type | Method and Description |
|---|---|
ClientResponse |
apply(ClientRequest clientRequest) |
Future<?> |
apply(ClientRequest request,
AsyncConnectorCallback callback) |
void |
close() |
org.apache.http.client.CookieStore |
getCookieStore()
Get the
CookieStore. |
org.apache.http.client.HttpClient |
getHttpClient()
Get the
HttpClient. |
String |
getName() |
public org.apache.http.client.HttpClient getHttpClient()
HttpClient.HttpClient.public org.apache.http.client.CookieStore getCookieStore()
CookieStore.CookieStore instance or null when set to
true.public ClientResponse apply(ClientRequest clientRequest) throws javax.ws.rs.ProcessingException
apply in interface Connectorapply in interface Inflector<ClientRequest,ClientResponse>javax.ws.rs.ProcessingExceptionpublic Future<?> apply(ClientRequest request, AsyncConnectorCallback callback)
Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.