Module bus.http

Class HttpProxy

java.lang.Object
org.miaixz.bus.http.plugin.httpx.HttpProxy

public class HttpProxy extends Object
Represents the configuration for an HTTP proxy server. This class holds the address, port, credentials, and type of the proxy.
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • hostAddress

      public final String hostAddress
      The proxy server's hostname or IP address.
    • port

      public final int port
      The proxy server's port number.
    • user

      public final String user
      The username for proxy authentication. Can be null if no authentication is required.
    • password

      public final String password
      The password for proxy authentication. Can be null if no authentication is required.
    • type

      public final Proxy.Type type
      The type of proxy (e.g., HTTP, SOCKS).
  • Constructor Details

    • HttpProxy

      public HttpProxy(String hostAddress, int port, String user, String password, Proxy.Type type)
      Constructs a new proxy configuration.
      Parameters:
      hostAddress - The hostname or IP address of the proxy server (e.g., "proxy.example.com", "192.168.1.1").
      port - The port number of the proxy server.
      user - The username for authentication, or null if not required.
      password - The password for authentication, or null if not required.
      type - The type of the proxy (e.g., Proxy.Type.HTTP).
    • HttpProxy

      public HttpProxy(String hostAddress, int port)
      Constructs a new HTTP proxy configuration without authentication.
      Parameters:
      hostAddress - The hostname or IP address of the proxy server.
      port - The port number of the proxy server.
  • Method Details

    • proxy

      public Proxy proxy()
      Creates a Proxy object from this configuration.
      Returns:
      A Proxy instance suitable for use with an HTTP client.
    • authenticator

      public Authenticator authenticator()
      Creates an Authenticator for this proxy configuration. This authenticator adds the 'Proxy-Authorization' header with Basic authentication credentials.
      Returns:
      An Authenticator instance.