Class OkHttpTransportBuilder
- Since:
- 9.2.1
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds and returns theOkHttpTransport.httpClient(okhttp3.OkHttpClient value) Sets the underlyingOkHttpClientto use.
-
Method Details
-
httpClient
Sets the underlyingOkHttpClientto use.If not set, a default client is created via
new OkHttpClient().A client with an explicit proxy makes
OkHttpTransport.supportsUrlPolicy()reportfalse (the proxy resolves the target host itself, bypassing the SSRF guard's address pinning), soRestRequestrefuses to send an SSRF-guard-active request through it. A client whoseProxySelectorroutes a guarded request through a proxy is refused at send time.The transport sends through a client derived from this one with
OkHttpClient.newBuilder()(it shares the connection pool, dispatcher and settings), adding a network interceptor that strips caller-set credential headers (Authorization,Cookieand the rest ofRedirectSecurity.stripOnCrossOrigin()) when OkHttp follows a redirect to a different origin. The client passed in is not modified.Once a hop has been stripped, later hops of the same call stay stripped, including one back to the first origin. That state travels on a tag of the request, so a network interceptor or an
Authenticatoron the client that builds a request from scratch (rather than fromrequest.newBuilder()) must preserve the request's tags, or the sticky strip is lost.OkHttp recommends sharing a single
OkHttpClientinstance across the application. When sharing, the caller is responsible for lifecycle management;OkHttpTransport.close()will still attempt to drain the client's connection pool and executor.- Parameters:
value- The client to use. Must not benull .- Returns:
- This object.
-
build
Builds and returns theOkHttpTransport.- Returns:
- A new instance. Never
null .
-