public final class HttpClientOptions extends ClientOptions
HttpClients.
HttpClient implementations may not support all configuration options in this class.
| Constructor and Description |
|---|
HttpClientOptions() |
| Modifier and Type | Method and Description |
|---|---|
Configuration |
getConfiguration()
Gets the configuration store that the
HttpClient will use. |
Duration |
getConnectionIdleTimeout()
Gets the duration of time before an idle connection is closed.
|
Integer |
getMaximumConnectionPoolSize()
Gets the maximum connection pool size used by the underlying HTTP client.
|
ProxyOptions |
getProxyOptions()
Gets the
proxy options that the HttpClient will use. |
Duration |
getReadTimeout()
Gets the read timeout duration used when reading the server response.
|
Duration |
getResponseTimeout()
Gets the response timeout duration used when waiting for a server to reply.
|
Duration |
getWriteTimeout()
Gets the write timeout for a request to be sent.
|
HttpClientOptions |
readTimeout(Duration readTimeout)
Sets the read timeout duration used when reading the server response.
|
HttpClientOptions |
responseTimeout(Duration responseTimeout)
Sets the response timeout duration used when waiting for a server to reply.
|
HttpClientOptions |
setApplicationId(String applicationId)
Sets the application ID.
|
HttpClientOptions |
setConfiguration(Configuration configuration)
Sets the configuration store that the
HttpClient will use. |
HttpClientOptions |
setConnectionIdleTimeout(Duration connectionIdleTimeout)
Sets the duration of time before an idle connection.
|
HttpClientOptions |
setHeaders(Iterable<Header> headers)
Sets the
Headers. |
HttpClientOptions |
setMaximumConnectionPoolSize(Integer maximumConnectionPoolSize)
Sets the maximum connection pool size used by the underlying HTTP client.
|
HttpClientOptions |
setProxyOptions(ProxyOptions proxyOptions)
Sets the
proxy options that the HttpClient will use. |
HttpClientOptions |
setReadTimeout(Duration readTimeout)
Sets the read timeout duration used when reading the server response.
|
HttpClientOptions |
setResponseTimeout(Duration responseTimeout)
Sets the response timeout duration used when waiting for a server to reply.
|
HttpClientOptions |
setWriteTimeout(Duration writeTimeout)
Sets the write timeout for a request to be sent.
|
getApplicationId, getHeaderspublic HttpClientOptions setApplicationId(String applicationId)
ClientOptions
The applicationId is used to configure UserAgentPolicy for telemetry/monitoring purposes.
See Azure Core: Telemetry policy for additional information.
Code Samples
Create ClientOptions with application ID 'myApplicationId'
ClientOptions clientOptions = new ClientOptions()
.setApplicationId("myApplicationId");
setApplicationId in class ClientOptionsapplicationId - The application ID.public HttpClientOptions setHeaders(Iterable<Header> headers)
ClientOptionsHeaders.
The passed headers are applied to each request sent with the client.
This overwrites all previously set headers.
Code Samples
Create ClientOptions with Header 'myCustomHeader':'myStaticValue'
ClientOptions clientOptions = new ClientOptions()
.setHeaders(Collections.singletonList(new Header("myCustomHeader", "myStaticValue")));
setHeaders in class ClientOptionsheaders - The headers.public HttpClientOptions setProxyOptions(ProxyOptions proxyOptions)
proxy options that the HttpClient will use.proxyOptions - The proxy options to use.public ProxyOptions getProxyOptions()
proxy options that the HttpClient will use.public HttpClientOptions setConfiguration(Configuration configuration)
HttpClient will use.configuration - The configuration store to use.public Configuration getConfiguration()
HttpClient will use.public HttpClientOptions setWriteTimeout(Duration writeTimeout)
The write timeout does not apply to the entire request but to each emission being sent over the wire. For example
a request body which emits 10 8KB buffers will trigger 10 write operations, the outbound
buffer will be periodically checked to determine if it is still draining.
If writeTimeout is null a 60 second timeout will be used, if it is a Duration less than
or equal to zero then no write timeout will be applied. When applying the timeout the greater of one millisecond
and the value of writeTimeout will be used.
By default the write timeout is 60 seconds.
writeTimeout - Write operation timeout duration.public Duration getWriteTimeout()
By default the write timeout is 60 seconds.
public HttpClientOptions responseTimeout(Duration responseTimeout)
The response timeout begins once the request write completes and finishes once the first response read is triggered when the server response is received.
If responseTimeout is null a 60 second timeout will be used, if it is a Duration less
than or equal to zero then no timeout will be applied to the response. When applying the timeout the greater of
one millisecond and the value of responseTimeout will be used.
By default the response timeout is 60 seconds.
responseTimeout - Response timeout duration.public HttpClientOptions setResponseTimeout(Duration responseTimeout)
The response timeout begins once the request write completes and finishes once the first response read is triggered when the server response is received.
If responseTimeout is null a 60 second timeout will be used, if it is a Duration less
than or equal to zero then no timeout will be applied to the response. When applying the timeout the greater of
one millisecond and the value of responseTimeout will be used.
By default the response timeout is 60 seconds.
responseTimeout - Response timeout duration.public Duration getResponseTimeout()
By default the response timeout is 60 seconds.
public HttpClientOptions readTimeout(Duration readTimeout)
The read timeout begins once the first response read is triggered after the server response is received. This timeout triggers periodically but won't fire its operation if another read operation has completed between when the timeout is triggered and completes.
If readTimeout is null a 60 second timeout will be used, if it is a Duration less than or
equal to zero then no timeout period will be applied to response read. When applying the timeout the greater of
one millisecond and the value of readTimeout will be used.
By default the read timeout is 60 seconds.
readTimeout - Read timeout duration.public HttpClientOptions setReadTimeout(Duration readTimeout)
The read timeout begins once the first response read is triggered after the server response is received. This timeout triggers periodically but won't fire its operation if another read operation has completed between when the timeout is triggered and completes.
If readTimeout is null a 60 second timeout will be used, if it is a Duration less than or
equal to zero then no timeout period will be applied to response read. When applying the timeout the greater of
one millisecond and the value of readTimeout will be used.
By default the read timeout is 60 seconds.
readTimeout - Read timeout duration.public Duration getReadTimeout()
By default the read timeout is 60 seconds.
public HttpClientOptions setMaximumConnectionPoolSize(Integer maximumConnectionPoolSize)
Modifying the maximum connection pool size may have effects on the performance of an application. Increasing the maximum connection pool will result in more connections being available for an application but may result in more contention for network resources. It is recommended to perform performance analysis on different maximum connection pool sizes to find the right configuration for an application.
This maximum connection pool size is not a global configuration but an instance level configuration for each
HttpClient created using this HttpClientOptions.
By default the maximum connection pool size is determined by the underlying HTTP client. Setting the maximum connection pool size to null resets the configuration to use the default determined by the underlying HTTP client.
maximumConnectionPoolSize - The maximum connection pool size.IllegalArgumentException - If maximumConnectionPoolSize is not null and is less than 1.public Integer getMaximumConnectionPoolSize()
Modifying the maximum connection pool size may have effects on the performance of an application. Increasing the maximum connection pool will result in more connections being available for an application but may result in more contention for network resources. It is recommended to perform performance analysis on different maximum connection pool sizes to find the right configuration for an application.
This maximum connection pool size is not a global configuration but an instance level configuration for each
HttpClient created using this HttpClientOptions.
By default the maximum connection pool size is determined by the underlying HTTP client. Setting the maximum connection pool size to null resets the configuration to use the default determined by the underlying HTTP client.
public HttpClientOptions setConnectionIdleTimeout(Duration connectionIdleTimeout)
The connection idle timeout begins once the connection has completed its last network request. Every time the connection is used the idle timeout will reset.
If connectionIdleTimeout is null a 60 second timeout will be used, if it is a Duration
less than or equal to zero then no timeout period will be applied. When applying the timeout the greater of one
millisecond and the value of connectionIdleTimeout will be used.
By default the connection idle timeout is 60 seconds.
connectionIdleTimeout - The connection idle timeout duration.public Duration getConnectionIdleTimeout()
By default the connection idle timeout is 60 seconds.
Copyright © 2021 Microsoft Corporation. All rights reserved.