Module bus.http

Class Address

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

public final class Address extends Object
A specification for a connection to an origin server. For an HTTP client, this is the server that terminates the HTTP request.

This class holds the configuration for a connection, including the server's hostname, port, proxy, and security settings. HTTP requests that share the same Address may also share the same underlying Connection.

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

    • Address

      public Address(String uriHost, int uriPort, DnsX dns, SocketFactory socketFactory, SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier, CertificatePinner certificatePinner, Authenticator proxyAuthenticator, Proxy proxy, List<org.miaixz.bus.core.net.Protocol> protocols, List<ConnectionSuite> connectionSuites, ProxySelector proxySelector)
      Constructs a new Address.
      Parameters:
      uriHost - the hostname of the origin server.
      uriPort - the port of the origin server.
      dns - the DNS service.
      socketFactory - the socket factory.
      sslSocketFactory - the SSL socket factory, or null for non-HTTPS connections.
      hostnameVerifier - the hostname verifier, or null for non-HTTPS connections.
      certificatePinner - the certificate pinner, or null for non-HTTPS connections.
      proxyAuthenticator - the proxy authenticator.
      proxy - the explicit proxy, or null to use the proxy selector.
      protocols - the list of supported protocols.
      connectionSuites - the list of supported connection suites.
      proxySelector - the proxy selector.
  • Method Details

    • url

      public UnoUrl url()
      Returns the URL of the origin server.

      The path, query, and fragment of this URL are always empty.

      Returns:
      the server's URL.
    • dns

      public DnsX dns()
      Returns the DNS service used to resolve hostnames for this address.
      Returns:
      the DNS service.
    • socketFactory

      public SocketFactory socketFactory()
      Returns the socket factory for this address.
      Returns:
      the socket factory.
    • proxyAuthenticator

      public Authenticator proxyAuthenticator()
      Returns the authenticator for proxy servers.
      Returns:
      the proxy authenticator.
    • protocols

      public List<org.miaixz.bus.core.net.Protocol> protocols()
      Returns the list of protocols supported by this address, such as http/1.1 and h2.
      Returns:
      an immutable list of protocols.
    • connectionSpecs

      public List<ConnectionSuite> connectionSpecs()
      Returns the list of connection suites supported by this address.
      Returns:
      an immutable list of connection suites.
    • proxySelector

      public ProxySelector proxySelector()
      Returns this address's proxy selector.
      Returns:
      the proxy selector.
    • proxy

      public Proxy proxy()
      Returns this address's explicitly specified proxy. This is null if a proxy selector is preferred.
      Returns:
      the explicit proxy, which may be null.
    • sslSocketFactory

      public SSLSocketFactory sslSocketFactory()
      Returns the SSL socket factory for this address, or null if this is not an HTTPS address.
      Returns:
      the SSL socket factory, or null.
    • hostnameVerifier

      public HostnameVerifier hostnameVerifier()
      Returns the hostname verifier for this address, or null if this is not an HTTPS address.
      Returns:
      the hostname verifier, or null.
    • certificatePinner

      public CertificatePinner certificatePinner()
      Returns the certificate pinner for this address, or null if this is not an HTTPS address.
      Returns:
      the certificate pinner, or null.
    • equals

      public boolean equals(Object other)
      Indicates whether some other object is "equal to" this one. Two addresses are equal if they share the same URL and non-host properties.
      Overrides:
      equals in class Object
      Parameters:
      other - the reference object with which to compare.
      Returns:
      true if this object is the same as the obj argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for the object. This is computed from the URL, DNS, proxy authenticator, protocols, connection suites, proxy selector, and SSL/TLS settings.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object.
    • toString

      public String toString()
      Returns a string representation of this address, including the host, port, and proxy information.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this address.