public final class HttpClientOptions extends ClientOptions
HttpClients.| Constructor and Description |
|---|
HttpClientOptions() |
| Modifier and Type | Method and Description |
|---|---|
Configuration |
getConfiguration()
Gets the configuration store that the
HttpClient will use. |
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 |
setHeaders(Iterable<Header> headers)
Sets the
Headers. |
HttpClientOptions |
setProxyOptions(ProxyOptions proxyOptions)
Sets the
proxy options that the HttpClient will use. |
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.
writeTimeout - Write operation timeout duration.public Duration getWriteTimeout()
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.
responseTimeout - Response timeout duration.public Duration getResponseTimeout()
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.
readTimeout - Read timeout duration.public Duration getReadTimeout()
Copyright © 2021 Microsoft Corporation. All rights reserved.