Class HttpUrlConnector
java.lang.Object
org.glassfish.jersey.client.internal.HttpUrlConnector
- All Implemented Interfaces:
Connector
,Inflector<ClientRequest,
ClientResponse>
Default client transport connector using
HttpURLConnection
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private final int
private final HttpUrlConnectorProvider.ConnectionFactory
private final boolean
private final boolean
private static final Logger
private static final String[]
private final boolean
private final LazyValue<SSLSocketFactory>
-
Constructor Summary
ConstructorsConstructorDescriptionHttpUrlConnector
(javax.ws.rs.client.Client client, HttpUrlConnectorProvider.ConnectionFactory connectionFactory, int chunkSize, boolean fixLengthStreaming, boolean setMethodWorkaround) Create newHttpUrlConnector
instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate ClientResponse
_apply
(ClientRequest request) apply
(ClientRequest request) Synchronously process client request into a response.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 InputStream
getName()
Get name of current connector.private boolean
isHeaderRestricted
(String name, String value) protected void
secureConnection
(JerseyClient client, HttpURLConnection uc) Secure connection if necessary.private void
setOutboundHeaders
(javax.ws.rs.core.MultivaluedMap<String, String> headers, HttpURLConnection uc) private static void
setRequestMethodViaJreBugWorkaround
(HttpURLConnection httpURLConnection, String method) Workaround for a bug inHttpURLConnection.setRequestMethod(String)
The implementation of Sun/Oracle is throwing aProtocolException
when the method is not in the list of the HTTP/1.1 default methods.
-
Field Details
-
LOGGER
-
ALLOW_RESTRICTED_HEADERS_SYSTEM_PROPERTY
- See Also:
-
restrictedHeaders
-
restrictedHeaderSet
-
connectionFactory
-
chunkSize
private final int chunkSize -
fixLengthStreaming
private final boolean fixLengthStreaming -
setMethodWorkaround
private final boolean setMethodWorkaround -
isRestrictedHeaderPropertySet
private final boolean isRestrictedHeaderPropertySet -
sslSocketFactory
-
-
Constructor Details
-
HttpUrlConnector
public HttpUrlConnector(javax.ws.rs.client.Client client, HttpUrlConnectorProvider.ConnectionFactory connectionFactory, int chunkSize, boolean fixLengthStreaming, boolean setMethodWorkaround) Create newHttpUrlConnector
instance.- Parameters:
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 thefixed-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. SeeHttpUrlConnectorProvider.SET_METHOD_WORKAROUND
for details.
-
-
Method Details
-
getInputStream
- Throws:
IOException
-
apply
Description copied from interface:Connector
Synchronously process client request into a response. The method is used by Jersey client runtime to synchronously send a request and receive a response.- Specified by:
apply
in interfaceConnector
- Specified by:
apply
in interfaceInflector<ClientRequest,
ClientResponse> - Parameters:
request
- Jersey client request to be sent.- Returns:
- Jersey client response received for the client request.
-
apply
Description copied from interface:Connector
Asynchronously process client request into a response. The method is used by Jersey client runtime to asynchronously send a request and receive a response. -
close
public void close()Description copied from interface:Connector
Close connector and release all it's internally associated resources. -
secureConnection
Secure connection if necessary. Provided implementation setsHostnameVerifier
andSSLSocketFactory
to give connection, if that is an instance ofHttpsURLConnection
.- Parameters:
client
- client associated with this client runtime.uc
- http connection to be secured.
-
_apply
- Throws:
IOException
-
setOutboundHeaders
private void setOutboundHeaders(javax.ws.rs.core.MultivaluedMap<String, String> headers, HttpURLConnection uc) -
isHeaderRestricted
-
setRequestMethodViaJreBugWorkaround
private static void setRequestMethodViaJreBugWorkaround(HttpURLConnection httpURLConnection, String method) Workaround for a bug inHttpURLConnection.setRequestMethod(String)
The implementation of Sun/Oracle is throwing aProtocolException
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-639 -
getName
Description copied from interface:Connector
Get name of current connector. Should contain identification of underlying specification and optionally version number. Will be used in User-Agent header.
-