org.apache.http.impl.conn

## Class DefaultClientConnectionOperator

- java.lang.Object
- - org.apache.http.impl.conn.DefaultClientConnectionOperator

- All Implemented Interfaces:
    ClientConnectionOperator

  Deprecated.
  (4.3) use `PoolingHttpClientConnectionManager`.

      @Deprecated
      @Contract(threading=SAFE_CONDITIONAL)
      public class DefaultClientConnectionOperator
      extends Object
      implements ClientConnectionOperator

  Default implementation of a `ClientConnectionOperator`. It uses a `SchemeRegistry` to look up `SchemeSocketFactory` objects.

  This connection operator is multihome network aware and will attempt to retry failed connects against all known IP addresses sequentially until the connect is successful or all known addresses fail to respond. Please note the same `CoreConnectionPNames.CONNECTION_TIMEOUT` value will be used for each connection attempt, so in the worst case the total elapsed time before timeout can be `CONNECTION_TIMEOUT * n` where `n` is the number of IP addresses of the given host. One can disable multihome support by overriding the `resolveHostname(String)` method and returning only one IP address for the given host name.

  The following parameters can be used to customize the behavior of this class:

  - `CoreProtocolPNames.HTTP_ELEMENT_CHARSET`
  - `CoreConnectionPNames.SO_TIMEOUT`
  - `CoreConnectionPNames.SO_LINGER`
  - `CoreConnectionPNames.SO_REUSEADDR`
  - `CoreConnectionPNames.TCP_NODELAY`
  - `CoreConnectionPNames.SOCKET_BUFFER_SIZE`
  - `CoreConnectionPNames.CONNECTION_TIMEOUT`
  - `CoreConnectionPNames.MAX_LINE_LENGTH`
  Since:
    4.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected DnsResolver` | `dnsResolver` Deprecated. the custom-configured DNS lookup mechanism.
    `protected SchemeRegistry` | `schemeRegistry` Deprecated. The scheme registry for looking up socket factories.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultClientConnectionOperator(SchemeRegistry schemes)` Deprecated. Creates a new client connection operator for the given scheme registry.
    `DefaultClientConnectionOperator(SchemeRegistry schemes, DnsResolver dnsResolver)` Deprecated. Creates a new client connection operator for the given scheme registry and the given custom DNS lookup mechanism.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `OperatedClientConnection` | `createConnection()` Deprecated. Creates a new connection that can be operated.
    `void` | `openConnection(OperatedClientConnection conn, org.apache.http.HttpHost target, InetAddress local, org.apache.http.protocol.HttpContext context, org.apache.http.params.HttpParams params)` Deprecated. Opens a connection to the given target host.
    `protected void` | `prepareSocket(Socket sock, org.apache.http.protocol.HttpContext context, org.apache.http.params.HttpParams params)` Deprecated. Performs standard initializations on a newly created socket.
    `protected InetAddress[]` | `resolveHostname(String host)` Deprecated. Resolves the given host name to an array of corresponding IP addresses, based on the configured name service on the provided DNS resolver.
    `void` | `updateSecureConnection(OperatedClientConnection conn, org.apache.http.HttpHost target, org.apache.http.protocol.HttpContext context, org.apache.http.params.HttpParams params)` Deprecated. Updates a connection with a layered secure connection.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### schemeRegistry

          protected final SchemeRegistry schemeRegistry

      Deprecated.
      The scheme registry for looking up socket factories.

    - #### dnsResolver

          protected final DnsResolver dnsResolver

      Deprecated.
      the custom-configured DNS lookup mechanism.

  - ### Constructor Detail

    - #### DefaultClientConnectionOperator

          public DefaultClientConnectionOperator(SchemeRegistry schemes)

      Deprecated.
      Creates a new client connection operator for the given scheme registry.
      Parameters:
        `schemes` - the scheme registry
      Since:
        4.2

    - #### DefaultClientConnectionOperator

          public DefaultClientConnectionOperator(SchemeRegistry schemes,
                                         DnsResolver dnsResolver)

      Deprecated.
      Creates a new client connection operator for the given scheme registry and the given custom DNS lookup mechanism.
      Parameters:
        `schemes` - the scheme registry
        `dnsResolver` - the custom DNS lookup mechanism

  - ### Method Detail

    - #### createConnection

          public OperatedClientConnection createConnection()

      Deprecated.
      Description copied from interface: `ClientConnectionOperator`
      Creates a new connection that can be operated.
      Specified by:
        `createConnection` in interface `ClientConnectionOperator`
      Returns:
        a new, unopened connection for use with this operator

    - #### openConnection

          public void openConnection(OperatedClientConnection conn,
                            org.apache.http.HttpHost target,
                            InetAddress local,
                            org.apache.http.protocol.HttpContext context,
                            org.apache.http.params.HttpParams params)
                              throws IOException

      Deprecated.
      Description copied from interface: `ClientConnectionOperator`
      Opens a connection to the given target host.
      Specified by:
        `openConnection` in interface `ClientConnectionOperator`
      Parameters:
        `conn` - the connection to open
        `target` - the target host to connect to
        `local` - the local address to route from, or `null` for the default
        `context` - the context for the connection
        `params` - the parameters for the connection
      Throws:
        `IOException` - in case of a problem

    - #### updateSecureConnection

          public void updateSecureConnection(OperatedClientConnection conn,
                                    org.apache.http.HttpHost target,
                                    org.apache.http.protocol.HttpContext context,
                                    org.apache.http.params.HttpParams params)
                                      throws IOException

      Deprecated.
      Description copied from interface: `ClientConnectionOperator`
      Updates a connection with a layered secure connection. The typical use of this method is to update a tunnelled plain connection (HTTP) to a secure TLS/SSL connection (HTTPS).
      Specified by:
        `updateSecureConnection` in interface `ClientConnectionOperator`
      Parameters:
        `conn` - the open connection to update
        `target` - the target host for the updated connection. The connection must already be open or tunnelled to the host and port, but the scheme of the target will be used to create a layered connection.
        `context` - the context for the connection
        `params` - the parameters for the updated connection
      Throws:
        `IOException` - in case of a problem

    - #### prepareSocket

          protected void prepareSocket(Socket sock,
                           org.apache.http.protocol.HttpContext context,
                           org.apache.http.params.HttpParams params)
                                throws IOException

      Deprecated.
      Performs standard initializations on a newly created socket.
      Parameters:
        `sock` - the socket to prepare
        `context` - the context for the connection
        `params` - the parameters from which to prepare the socket
      Throws:
        `IOException` - in case of an IO problem

    - #### resolveHostname

          protected InetAddress[] resolveHostname(String host)
                                           throws UnknownHostException

      Deprecated.
      Resolves the given host name to an array of corresponding IP addresses, based on the configured name service on the provided DNS resolver. If one wasn't provided, the system configuration is used.
      Parameters:
        `host` - host name to resolve
      Returns:
        array of IP addresses
      Throws:
        `UnknownHostException` - if no IP address for the host could be determined.
      Since:
        4.1
      See Also:
        `DnsResolver`, `SystemDefaultDnsResolver`

Copyright © 1999–2022 The Apache Software Foundation. All rights reserved.