Class HttpProxy


public class HttpProxy extends ProxyConfiguration.Proxy

Client-side proxy configuration for HTTP proxying, as specified by RFC 9110.

By default the communication between client and proxy happens using the HTTP/1.1 protocol, but it may be configured to use also other HTTP protocol versions, such as HTTP/2.

  • Constructor Details

    • HttpProxy

      public HttpProxy(String host, int port)

      Creates a new instance with the given HTTP proxy host and port.

      Parameters:
      host - the HTTP proxy host name
      port - the HTTP proxy port
    • HttpProxy

      public HttpProxy(Origin.Address address, boolean secure)

      Creates a new instance with the given HTTP proxy address.

      When secure=true the communication between the client and the proxy will be encrypted (using this proxy ProxyConfiguration.Proxy.getSslContextFactory() which typically defaults to that of HttpClient.

      Parameters:
      address - the HTTP proxy address (host and port)
      secure - whether the communication between the client and the HTTP proxy should be secure
    • HttpProxy

      public HttpProxy(Origin.Address address, boolean secure, Origin.Protocol protocol)

      Creates a new instance with the given HTTP proxy address and protocol.

      Parameters:
      address - the HTTP proxy address (host and port)
      secure - whether the communication between the client and the HTTP proxy should be secure
      protocol - the protocol to use to communicate with the HTTP proxy
    • HttpProxy

      public HttpProxy(Origin.Address address, SslContextFactory.Client sslContextFactory)

      Creates a new instance with the given HTTP proxy address and TLS configuration.

      The SslContextFactory could have a different configuration from the one configured in HttpClient, and it is used to communicate with the HTTP proxy only (not to communicate with the servers).

      Parameters:
      address - the HTTP proxy address (host and port)
      sslContextFactory - the SslContextFactory.Client to use to communicate with the HTTP proxy
    • HttpProxy

      public HttpProxy(Origin.Address address, SslContextFactory.Client sslContextFactory, Origin.Protocol protocol)

      Creates a new instance with the given HTTP proxy address, TLS configuration and protocol.

      The SslContextFactory could have a different configuration from the one configured in HttpClient and it is used to communicate with the HTTP proxy only (not to communicate with the servers).

      Parameters:
      address - the HTTP proxy address (host and port)
      sslContextFactory - the SslContextFactory.Client to use to communicate with the HTTP proxy
      protocol - the protocol to use to communicate with the HTTP proxy
    • HttpProxy

      public HttpProxy(Origin origin, SslContextFactory.Client sslContextFactory)

      Creates a new instance with the given HTTP proxy Origin and TLS configuration.

      The SslContextFactory could have a different configuration from the one configured in HttpClient and it is used to communicate with the HTTP proxy only (not to communicate with the servers).

      Parameters:
      origin - the HTTP proxy Origin information
      sslContextFactory - the SslContextFactory.Client to use to communicate with the HTTP proxy
  • Method Details