Module bus.http

Class ConnectionSelector

java.lang.Object
org.miaixz.bus.http.accord.ConnectionSelector

public final class ConnectionSelector extends Object
Handles the fallback strategy for connection specifications: when a secure socket connection fails due to a handshake or protocol issue, the connection may be retried with a different protocol. Instances are stateful and should be created and used for a single connection attempt.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • ConnectionSelector

      public ConnectionSelector(List<ConnectionSuite> connectionSuites)
      Constructor
      Parameters:
      connectionSuites - The list of connection suites.
  • Method Details

    • configureSecureSocket

      public ConnectionSuite configureSecureSocket(SSLSocket sslSocket) throws IOException
      Configures the SSLSocket with the appropriate ConnectionSuite for connecting to the specified host. Returns a ConnectionSuite and will not return null.
      Parameters:
      sslSocket - The SSL socket to configure.
      Returns:
      The configuration for the socket connection.
      Throws:
      IOException - if the socket does not support any of the available TLS modes.
    • connectionFailed

      public boolean connectionFailed(IOException ex)
      Reports a connection failure. Determines the next ConnectionSuite to try, if any.
      Parameters:
      ex - The exception that occurred.
      Returns:
      true if the connection should be retried with configureSecureSocket(SSLSocket), or false if no further retries are necessary.