Package org.apache.juneau.rest.client
Class JavaHttpTransportBuilder
java.lang.Object
org.apache.juneau.rest.client.JavaHttpTransportBuilder
- Since:
- 9.2.1
-
Method Summary
Modifier and TypeMethodDescriptionOpts in to sending a caller-controlledHostheader, which pinning a policy-covered HTTP request needs.build()Builds and returns theJavaHttpTransport.httpClient(HttpClient value) Sets the underlyingHttpClientto use.maxResponseBytes(long value) Sets the maximum number of response body bytes the transport delivers; reading further fails with anIOException.
-
Method Details
-
allowHostHeaderOverride
Opts in to sending a caller-controlledHostheader, which pinning a policy-covered HTTP request needs.The JDK
HttpClientrejects aHostheader unless the JVM propertyjdk.httpclient.allowRestrictedHeaderslists it. Without this opt-in a policy-covered HTTP request that needs aHostoverride fails closed.This setting changes a JVM-wide property. Building the transport adds
hostto the system propertyjdk.httpclient.allowRestrictedHeaders, which affects everyHttpClientin the JVM. The JDK reads the property once, the first time any code builds a request header, so it only takes effect if that has not happened yet; otherwise start the JVM with-Djdk.httpclient.allowRestrictedHeaders=host.- Returns:
- This object.
-
maxResponseBytes
Sets the maximum number of response body bytes the transport delivers; reading further fails with anIOException.- Parameters:
value- The cap in bytes. Zero or negative means unlimited. Defaults toJavaHttpTransport.DEFAULT_MAX_RESPONSE_BYTES.- Returns:
- This object.
-
httpClient
Sets the underlyingHttpClientto use.If not set, a default client is created via
HttpClient.newHttpClient().- Parameters:
value- The client to use. Can benull (a default client is created viaHttpClient.newHttpClient()).- Returns:
- This object.
-
build
Builds and returns theJavaHttpTransport.- Returns:
- A new instance. Never
null .
-