Class JdkHttpClientBuilder
- All Implemented Interfaces:
HttpClientBuilder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()connectTimeout(Duration connectTimeout) httpClientBuilder(HttpClient.Builder httpClientBuilder) Sets the JDKHttpClient.Builderused to create the underlying client.readTimeout(Duration readTimeout) booleanstreamingBackpressure(boolean streamingBackpressure) Controls whetherstream(...)propagates subscriber demand to HTTP body reads.streamingBufferSize(Integer streamingBufferSize) Sets the size of the bounded back-pressure buffer used by the streaming (stream) path.
-
Constructor Details
-
JdkHttpClientBuilder
public JdkHttpClientBuilder()
-
-
Method Details
-
httpClientBuilder
-
httpClientBuilder
Sets the JDKHttpClient.Builderused to create the underlying client.When not set, a default client is used: plain
http://requests are sent over HTTP/1.1, andhttps://requests use HTTP/2 when the server supports it.When set, the HTTP version configured on the given builder is used for all requests. If no version is configured, the JDK default is HTTP/2, which for plain
http://URLs sends anUpgrade: h2crequest that many servers do not handle correctly (for example, they ignore the request body). Call.version(java.net.http.HttpClient.Version.HTTP_1_1)on the builder to avoid this.- Parameters:
httpClientBuilder- the JDK HTTP client builder- Returns:
- this builder
-
connectTimeout
- Specified by:
connectTimeoutin interfaceHttpClientBuilder
-
connectTimeout
- Specified by:
connectTimeoutin interfaceHttpClientBuilder
-
readTimeout
- Specified by:
readTimeoutin interfaceHttpClientBuilder
-
readTimeout
- Specified by:
readTimeoutin interfaceHttpClientBuilder
-
streamingBufferSize
- Returns:
- the bounded back-pressure buffer size used by
stream(...), ornullfor the default. - Since:
- 1.20.0
-
streamingBufferSize
Sets the size of the bounded back-pressure buffer used by the streaming (stream) path. Server-sent events are relayed to the subscriber through this buffer; if the subscriber consumes slower than the server produces and the buffer overflows, the stream terminates with an error.The default is 16384. Cannot be combined with
streamingBackpressure(true), which does not use this buffer.- Parameters:
streamingBufferSize- the buffer size; must be greater than zero- Returns:
- the builder instance
- Since:
- 1.20.0
-
streamingBackpressure
- Returns:
- whether streaming HTTP body reads follow downstream demand
- Since:
- 1.23.0
-
streamingBackpressure
Controls whetherstream(...)propagates subscriber demand to HTTP body reads. When enabled, the client drains the parsed events from the current byte batch before requesting more body data. A slow subscriber pauses body consumption instead of overflowing the event buffer. The parser can still retain an incomplete event spanning several byte batches.Disabled by default to retain the bounded event-buffer behavior used by existing integrations. This option applies only to the publisher streaming API, not blocking or callback-based requests. Cannot be combined with
streamingBufferSize(Integer):build()throws anIllegalArgumentExceptionif both are set.- Parameters:
streamingBackpressure- whether to make streaming body reads follow subscriber demand- Returns:
- this builder
- Since:
- 1.23.0
-
build
- Specified by:
buildin interfaceHttpClientBuilder
-