public class HttpUrlConnector extends java.lang.Object implements Connector
HttpURLConnection.| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
ALLOW_RESTRICTED_HEADERS_SYSTEM_PROPERTY |
private int |
chunkSize |
private HttpUrlConnectorProvider.ConnectionFactory |
connectionFactory |
private boolean |
fixLengthStreaming |
private boolean |
isRestrictedHeaderPropertySet |
private static java.util.logging.Logger |
LOGGER |
private static java.lang.String[] |
restrictedHeaders |
private static java.util.Set<java.lang.String> |
restrictedHeaderSet |
private boolean |
setMethodWorkaround |
private LazyValue<javax.net.ssl.SSLSocketFactory> |
sslSocketFactory |
| Constructor and Description |
|---|
HttpUrlConnector(javax.ws.rs.client.Client client,
HttpUrlConnectorProvider.ConnectionFactory connectionFactory,
int chunkSize,
boolean fixLengthStreaming,
boolean setMethodWorkaround)
Create new
HttpUrlConnector instance. |
| Modifier and Type | Method and Description |
|---|---|
private ClientResponse |
_apply(ClientRequest request) |
ClientResponse |
apply(ClientRequest request)
Synchronously process client request into a response.
|
java.util.concurrent.Future<?> |
apply(ClientRequest request,
AsyncConnectorCallback callback)
Asynchronously process client request into a response.
|
void |
close()
Close connector and release all it's internally associated resources.
|
private static java.io.InputStream |
getInputStream(java.net.HttpURLConnection uc) |
java.lang.String |
getName()
Get name of current connector.
|
private boolean |
isHeaderRestricted(java.lang.String name,
java.lang.String value) |
protected void |
secureConnection(JerseyClient client,
java.net.HttpURLConnection uc)
Secure connection if necessary.
|
private void |
setOutboundHeaders(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> headers,
java.net.HttpURLConnection uc) |
private static void |
setRequestMethodViaJreBugWorkaround(java.net.HttpURLConnection httpURLConnection,
java.lang.String method)
Workaround for a bug in
HttpURLConnection.setRequestMethod(String)
The implementation of Sun/Oracle is throwing a ProtocolException
when the method is not in the list of the HTTP/1.1 default methods. |
private static final java.util.logging.Logger LOGGER
private static final java.lang.String ALLOW_RESTRICTED_HEADERS_SYSTEM_PROPERTY
private static final java.lang.String[] restrictedHeaders
private static final java.util.Set<java.lang.String> restrictedHeaderSet
private final HttpUrlConnectorProvider.ConnectionFactory connectionFactory
private final int chunkSize
private final boolean fixLengthStreaming
private final boolean setMethodWorkaround
private final boolean isRestrictedHeaderPropertySet
private final LazyValue<javax.net.ssl.SSLSocketFactory> sslSocketFactory
public HttpUrlConnector(javax.ws.rs.client.Client client,
HttpUrlConnectorProvider.ConnectionFactory connectionFactory,
int chunkSize,
boolean fixLengthStreaming,
boolean setMethodWorkaround)
HttpUrlConnector instance.client - JAX-RS client instance for which the connector is being created.connectionFactory - HttpsURLConnection factory to be used when creating connections.chunkSize - chunk size to use when using HTTP chunked transfer coding.fixLengthStreaming - specify if the the fixed-length streaming mode on the underlying HTTP URL connection instances should be
used when sending requests.setMethodWorkaround - specify if the reflection workaround should be used to set HTTP URL connection method
name. See HttpUrlConnectorProvider.SET_METHOD_WORKAROUND for details.private static java.io.InputStream getInputStream(java.net.HttpURLConnection uc)
throws java.io.IOException
java.io.IOExceptionpublic ClientResponse apply(ClientRequest request)
Connectorapply in interface Connectorapply in interface Inflector<ClientRequest,ClientResponse>request - Jersey client request to be sent.public java.util.concurrent.Future<?> apply(ClientRequest request, AsyncConnectorCallback callback)
Connectorpublic void close()
Connectorprotected void secureConnection(JerseyClient client, java.net.HttpURLConnection uc)
HostnameVerifier and SSLSocketFactory to give connection, if that
is an instance of HttpsURLConnection.client - client associated with this client runtime.uc - http connection to be secured.private ClientResponse _apply(ClientRequest request) throws java.io.IOException
java.io.IOExceptionprivate void setOutboundHeaders(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> headers,
java.net.HttpURLConnection uc)
private boolean isHeaderRestricted(java.lang.String name,
java.lang.String value)
private static void setRequestMethodViaJreBugWorkaround(java.net.HttpURLConnection httpURLConnection,
java.lang.String method)
HttpURLConnection.setRequestMethod(String)
The implementation of Sun/Oracle is throwing a ProtocolException
when the method is not in the list of the HTTP/1.1 default methods.
This means that to use e.g. PROPFIND and others, we must apply this workaround.
See issue http://java.net/jira/browse/JERSEY-639public java.lang.String getName()
Connector