Class ProxyConfigBuilder<A>

java.lang.Object
io.servicetalk.http.api.ProxyConfigBuilder<A>
Type Parameters:
A - the type of address

public final class ProxyConfigBuilder<A> extends Object
Builder for ProxyConfig.
  • Constructor Details

    • ProxyConfigBuilder

      public ProxyConfigBuilder(A address)
      Creates a new instance.
      Parameters:
      address - Proxy address
      See Also:
  • Method Details

    • connectRequestHeadersInitializer

      public ProxyConfigBuilder<A> connectRequestHeadersInitializer(Consumer<HttpHeaders> connectRequestHeadersInitializer)
      Sets an initializer for HttpHeaders related to HTTP/1.1 CONNECT request.
      Parameters:
      connectRequestHeadersInitializer - Consumer that can be used to set custom HttpHeaders for HTTP/1.1 CONNECT request (auth, tracing, etc.)
      Returns:
      this
      See Also:
    • sslConfig

      public ProxyConfigBuilder<A> sslConfig(@Nullable ClientSslConfig sslConfig)
      Sets the ClientSslConfig for the TLS handshake to the proxy itself.

      Distinct from the origin SSL config configured via SingleAddressHttpClientBuilder.sslConfig(ClientSslConfig), which applies to the inner TLS handshake performed after the HTTP/1.1 CONNECT tunnel is established. peerHost, peerPort, and sniHostname default from the proxy address when unset; ALPN is restricted to http/1.1. See ProxyConfig.sslConfig() for details.

      Note on proxy mode (CONNECT vs forward): ServiceTalk currently does not have an explicit knob for selecting CONNECT-proxy vs forward-proxy semantics. The choice is implicitly determined by whether the parent origin SSL is set: setting it routes through CONNECT; leaving it unset routes through forward-proxy mode (absolute-URI request lines). Proxy SSL set here is orthogonal — it applies to the hop to the proxy regardless of which mode was inferred. Supported combinations:

      • proxy SSL no, origin SSL no → plaintext forward proxy
      • proxy SSL no, origin SSL yes → plaintext CONNECT, inner TLS to origin
      • proxy SSL yes, origin SSL yes → TLS to CONNECT proxy, inner TLS to origin (layered TLS)

      The combination "proxy SSL set + origin SSL unset" is rejected at build time (IllegalStateException) as this makes it difficult to reason about security.

      Parameters:
      sslConfig - the ClientSslConfig for the proxy TLS stage, or null for plaintext to the proxy.
      Returns:
      this
      Throws:
      IllegalArgumentException - if sslConfig advertises any ALPN protocol other than http/1.1. The proxy TLS session always carries an HTTP/1.1 CONNECT exchange, so any non-http/1.1 ALPN advertised here would risk the proxy negotiating a protocol on which CONNECT is not defined.
      See Also:
    • build

      public ProxyConfig<A> build()
      Builds a new ProxyConfig.
      Returns:
      a new ProxyConfig.