public interface HttpClientSpec
Modifier and Type | Method and Description |
---|---|
HttpClientSpec |
byteBufAllocator(io.netty.buffer.ByteBufAllocator byteBufAllocator)
The buffer allocator to use.
|
HttpClientSpec |
connectTimeout(java.time.Duration connectTimeout)
The connect timeout value for requests.
|
HttpClientSpec |
enableMetricsCollection(boolean enableMetricsCollection)
Enable metric collection on HTTP Client.
|
HttpClientSpec |
errorIntercept(Action<? super java.lang.Throwable> interceptor)
Add an interceptor for errors thrown by this client (eg.
|
HttpClientSpec |
idleTimeout(java.time.Duration idleTimeout)
The default amount of time to allow a connection to remain idle in the connection pool.
|
HttpClientSpec |
maxContentLength(int maxContentLength)
The maximum size to allow for responses.
|
HttpClientSpec |
poolQueueSize(int poolQueueSize)
The maximum number of requests that will be queued if connection pool was depleted.
|
HttpClientSpec |
poolSize(int poolSize)
The maximum number of connections to maintain to a given protocol/host/port.
|
HttpClientSpec |
proxy(Action<? super ProxySpec> proxy)
Configure a HTTP proxy for outgoing calls from this client.
|
HttpClientSpec |
readTimeout(java.time.Duration readTimeout)
The read timeout value for responses.
|
HttpClientSpec |
requestIntercept(Action<? super RequestSpec> interceptor)
Add an interceptor for all requests handled by this client.
|
HttpClientSpec |
responseIntercept(Action<? super HttpResponse> interceptor)
Add an interceptor for all responses returned by this client.
|
HttpClientSpec |
responseIntercept(Operation operation)
Execute the provide
Operation for all responses returned by this client. |
HttpClientSpec |
responseMaxChunkSize(int numBytes)
The max size of the chunks to emit when reading a response as a stream.
|
HttpClientSpec byteBufAllocator(io.netty.buffer.ByteBufAllocator byteBufAllocator)
Defaults to PooledByteBufAllocator.DEFAULT
.
byteBufAllocator
- the buffer allocatorthis
HttpClientSpec poolSize(int poolSize)
Defaults to 0.
Setting this number to > 0 enables connection pooling (a.k.a. HTTP Keep Alive).
The given value dictates the number of connections to a given target, not the overall size.
Calling HttpClient.close()
will close all current connections.
poolSize
- the connection pool sizethis
HttpClientSpec poolQueueSize(int poolQueueSize)
Defaults to Integer.MAX_VALUE
.
Setting this option is recommended, because the http client queues requests when the pool is depleted. Once a connection is available, the request is processed and all resources released.
The option is not applied if pool size is not set.
poolQueueSize
- the connection pool queue sizethis
HttpClientSpec idleTimeout(java.time.Duration idleTimeout)
If the connection is idle for the timeout value, it will be closed.
A value of Duration.ZERO
is interpreted as no timeout.
The value is never Duration.isNegative()
.
this
HttpClientSpec maxContentLength(int maxContentLength)
Defaults to ServerConfig.DEFAULT_MAX_CONTENT_LENGTH
.
maxContentLength
- the maximum response content lengththis
HttpClientSpec readTimeout(java.time.Duration readTimeout)
Defaults to 30 seconds.
readTimeout
- the read timeout value for responsesthis
HttpClientSpec connectTimeout(java.time.Duration connectTimeout)
Defaults to 30 seconds.
connectTimeout
- the connect timeout value for requeststhis
HttpClientSpec responseMaxChunkSize(int numBytes)
Defaults to 8192.
Increasing this value can increase throughput at the expense of memory use.
numBytes
- the max number of bytes to emitthis
HttpClientSpec requestIntercept(Action<? super RequestSpec> interceptor)
This function is additive.
interceptor
- the action to perform on the spec before transmitting.HttpClientSpec responseIntercept(Action<? super HttpResponse> interceptor)
This function is additive.
interceptor
- the action to perform on the response before returning.this
HttpClientSpec responseIntercept(Operation operation)
Operation
for all responses returned by this client.
This function will wrap the provided operation and subscribe to it.
This function is additive with responseIntercept(Action)
.
operation
- the operation to subscribe to before return the response.this
HttpClientSpec errorIntercept(Action<? super java.lang.Throwable> interceptor)
This function is additive.
interceptor
- the action to perform on the error before propagating.this
HttpClientSpec enableMetricsCollection(boolean enableMetricsCollection)
Defaults to false.
enableMetricsCollection
- A boolean used to enable metric collection.this
HttpClientSpec proxy(Action<? super ProxySpec> proxy)
proxy
- the proxy configurationthis