Class HttpUrlConnector

java.lang.Object
org.glassfish.jersey.client.internal.HttpUrlConnector
All Implemented Interfaces:
Connector, Inflector<ClientRequest,ClientResponse>

public class HttpUrlConnector extends Object implements Connector
Default client transport connector using HttpURLConnection.
Author:
Marek Potociar
  • Constructor Details

    • HttpUrlConnector

      public HttpUrlConnector(Client client, HttpUrlConnectorProvider.ConnectionFactory connectionFactory, int chunkSize, boolean fixLengthStreaming, boolean setMethodWorkaround)
      Create new HttpUrlConnector 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 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.
  • Method Details

    • apply

      public ClientResponse apply(ClientRequest request)
      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 interface Connector
      Specified by:
      apply in interface Inflector<ClientRequest,ClientResponse>
      Parameters:
      request - Jersey client request to be sent.
      Returns:
      Jersey client response received for the client request.
    • apply

      public Future<?> apply(ClientRequest request, AsyncConnectorCallback callback)
      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.
      Specified by:
      apply in interface Connector
      Parameters:
      request - Jersey client request to be sent.
      callback - Jersey asynchronous connector callback to asynchronously receive the request processing result (either a response or a failure).
      Returns:
      asynchronously executed task handle.
    • close

      public void close()
      Description copied from interface: Connector
      Close connector and release all it's internally associated resources.
      Specified by:
      close in interface Connector
    • secureConnection

      protected void secureConnection(JerseyClient client, HttpURLConnection uc)
      Secure connection if necessary.

      Provided implementation sets HostnameVerifier and SSLSocketFactory to give connection, if that is an instance of HttpsURLConnection.

      Parameters:
      client - client associated with this client runtime.
      uc - http connection to be secured.
    • getName

      public String 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.
      Specified by:
      getName in interface Connector
      Returns:
      name of current connector. Returning null or empty string means not including this information in a generated "User-Agent" header.