Module bus.http

Class Route

java.lang.Object
org.miaixz.bus.http.Route

public final class Route extends Object
Represents a specific route to an origin server chosen by the HTTP client when making a connection.

A route encapsulates the specific configuration for a connection, including the target address, the proxy to use, and the socket address. Each route is an immutable instance representing a concrete choice of the client's connection options (like proxy selection, TLS configuration).

Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • Route

      public Route(Address address, Proxy proxy, InetSocketAddress inetSocketAddress)
      Constructs a new Route instance.
      Parameters:
      address - The address configuration for the target server.
      proxy - The proxy to use for the connection.
      inetSocketAddress - The target socket address.
      Throws:
      NullPointerException - if address, proxy, or inetSocketAddress is null.
  • Method Details

    • address

      public Address address()
      Returns the address configuration for the target server.
      Returns:
      The Address object.
    • proxy

      public Proxy proxy()
      Returns the proxy used for this route.

      Warning: This may be different from the proxy in the address configuration if a proxy selector is used and the address does not specify a proxy.

      Returns:
      The Proxy object.
    • socketAddress

      public InetSocketAddress socketAddress()
      Returns the target socket address.
      Returns:
      The InetSocketAddress object, representing the target IP and port.
    • requiresTunnel

      public boolean requiresTunnel()
      Returns whether this route requires an HTTPS tunnel through an HTTP proxy.

      See RFC 2817, Section 5.2.

      Returns:
      true if this route requires an HTTPS tunnel.
    • equals

      public boolean equals(Object other)
      Compares this route to another object for equality.

      Two routes are equal if their address, proxy, and socket address are all equal.

      Overrides:
      equals in class Object
      Parameters:
      other - The other object to compare against.
      Returns:
      true if the two routes are equal.
    • hashCode

      public int hashCode()
      Computes the hash code for this route.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code value.
    • toString

      public String toString()
      Returns a string representation of this route.
      Overrides:
      toString in class Object
      Returns:
      A string containing the socket address.