Class ProxyConfigBuilder<A>
- Type Parameters:
A- the type of address
ProxyConfig.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a newProxyConfig.connectRequestHeadersInitializer(Consumer<HttpHeaders> connectRequestHeadersInitializer) Sets an initializer forHttpHeadersrelated to HTTP/1.1 CONNECT request.sslConfig(ClientSslConfig sslConfig) Sets theClientSslConfigfor the TLS handshake to the proxy itself.
-
Constructor Details
-
ProxyConfigBuilder
Creates a new instance.- Parameters:
address- Proxy address- See Also:
-
-
Method Details
-
connectRequestHeadersInitializer
public ProxyConfigBuilder<A> connectRequestHeadersInitializer(Consumer<HttpHeaders> connectRequestHeadersInitializer) Sets an initializer forHttpHeadersrelated to HTTP/1.1 CONNECT request.- Parameters:
connectRequestHeadersInitializer-Consumerthat can be used to set customHttpHeadersforHTTP/1.1 CONNECTrequest (auth, tracing, etc.)- Returns:
this- See Also:
-
sslConfig
Sets theClientSslConfigfor 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 theHTTP/1.1 CONNECTtunnel is established.peerHost,peerPort, andsniHostnamedefault from the proxyaddresswhen unset; ALPN is restricted tohttp/1.1. SeeProxyConfig.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 SSLis set: setting it routes throughCONNECT; 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- theClientSslConfigfor the proxy TLS stage, ornullfor plaintext to the proxy.- Returns:
this- Throws:
IllegalArgumentException- ifsslConfigadvertises any ALPN protocol other thanhttp/1.1. The proxy TLS session always carries an HTTP/1.1 CONNECT exchange, so any non-http/1.1ALPN advertised here would risk the proxy negotiating a protocol on which CONNECT is not defined.- See Also:
-
build
Builds a newProxyConfig.- Returns:
- a new
ProxyConfig.
-