Class ProxyOptions

java.lang.Object
io.vertx.core.net.ProxyOptions

public class ProxyOptions extends Object
Proxy options for a net client or a net client.
Author:
Alexander Lehmann
  • Field Details

    • DEFAULT_TYPE

      public static final ProxyType DEFAULT_TYPE
      The default proxy type (HTTP)
    • DEFAULT_PORT

      public static final int DEFAULT_PORT
      The default port for proxy connect = 3128

      3128 is the default port for Squid

      See Also:
    • DEFAULT_HOST

      public static final String DEFAULT_HOST
      The default hostname for proxy connect = "localhost"
      See Also:
    • DEFAULT_CONNECT_TIMEOUT

      public static final Duration DEFAULT_CONNECT_TIMEOUT
      The default timeout for proxy connect = 10 seconds
  • Constructor Details

    • ProxyOptions

      public ProxyOptions()
      Default constructor.
    • ProxyOptions

      public ProxyOptions(ProxyOptions other)
      Copy constructor.
      Parameters:
      other - the options to copy
    • ProxyOptions

      public ProxyOptions(JsonObject json)
      Create options from JSON.
      Parameters:
      json - the JSON
  • Method Details

    • toJson

      public JsonObject toJson()
      Convert to JSON
      Returns:
      the JSON
    • getHost

      public String getHost()
      Get proxy host.
      Returns:
      proxy hosts
    • setHost

      public ProxyOptions setHost(String host)
      Set proxy host.
      Parameters:
      host - the proxy host to connect to
      Returns:
      a reference to this, so the API can be used fluently
    • getPort

      public int getPort()
      Get proxy port.
      Returns:
      proxy port
    • setPort

      public ProxyOptions setPort(int port)
      Set proxy port.
      Parameters:
      port - the proxy port to connect to
      Returns:
      a reference to this, so the API can be used fluently
    • getUsername

      public String getUsername()
      Get proxy username.
      Returns:
      proxy username
    • setUsername

      public ProxyOptions setUsername(String username)
      Set proxy username.
      Parameters:
      username - the proxy username
      Returns:
      a reference to this, so the API can be used fluently
    • getPassword

      public String getPassword()
      Get proxy password.
      Returns:
      proxy password
    • setPassword

      public ProxyOptions setPassword(String password)
      Set proxy password.
      Parameters:
      password - the proxy password
      Returns:
      a reference to this, so the API can be used fluently
    • getProxyAuthorization

      public String getProxyAuthorization()
      Get the Proxy-Authorization header value.
      Returns:
      the Proxy-Authorization header value
    • setProxyAuthorization

      public ProxyOptions setProxyAuthorization(String proxyAuthorization)
      Set the Proxy-Authorization header value.

      When set, this value is sent instead of the Basic value derived from the username and password.

      Parameters:
      proxyAuthorization - the Proxy-Authorization header value
      Returns:
      a reference to this, so the API can be used fluently
    • getType

      public ProxyType getType()
      Get proxy type.

      ProxyType can be HTTP, SOCKS4 and SOCKS5

      Returns:
      proxy type
    • setType

      public ProxyOptions setType(ProxyType type)
      Set proxy type.

      ProxyType can be HTTP, SOCKS4 and SOCKS5

      Parameters:
      type - the proxy type to connect to
      Returns:
      a reference to this, so the API can be used fluently
    • getConnectTimeout

      public Duration getConnectTimeout()
      Get the connection timeout , defaults to 10 seconds.

      A connection to the proxy is considered successful when:

      • the client received a 200 response to the CONNECT request for HTTP proxies, or
      • the SOCKS handshake ended with the SUCCESS status, for SOCKS proxies.
      Returns:
      the connection timeout
    • setConnectTimeout

      public ProxyOptions setConnectTimeout(Duration connectTimeout)
      Set the connection timeout.
      Parameters:
      connectTimeout - the connection timeout
      Returns:
      a reference to this, so the API can be used fluently
    • getSslOptions

      public ClientSSLOptions getSslOptions()
      Get the SSL options used between the client and the proxy.

      Only relevant when getType() is ProxyType.HTTPS.

      Returns:
      the proxy SSL options, or null
    • setSslOptions

      public ProxyOptions setSslOptions(ClientSSLOptions sslOptions)
      Set the SSL options used for the connection to the proxy itself, when the proxy is reached over SSL/TLS (ProxyType.HTTPS).

      These options are resolved independently of the origin SSL options, so the proxy presents and is validated against its own certificate and trust store. When left unset for an ProxyType.HTTPS proxy, the connection is still established over SSL/TLS using the default trust source, with hostname verification enabled against the proxy host.

      Parameters:
      sslOptions - the proxy SSL options
      Returns:
      a reference to this, so the API can be used fluently