public abstract static class HttpClient.Builder extends Object
HttpClient
s. HttpClient.Builder
s
are created by calling HttpClient.create()
.
Each of the setter methods in this class modifies the state of the builder and returns this (ie. the same instance). The methods are not synchronized and should not be called from multiple threads without external synchronization.
build()
returns a new HttpClient
each time it is
called.
Modifier and Type | Method | Description |
---|---|---|
abstract HttpClient.Builder |
authenticator(Authenticator a) |
Sets an authenticator to use for HTTP authentication.
|
abstract HttpClient |
build() |
Returns a
HttpClient built from the current state of this
builder. |
abstract HttpClient.Builder |
cookieManager(CookieManager manager) |
Sets a cookie manager.
|
abstract HttpClient.Builder |
executorService(ExecutorService s) |
Sets the ExecutorService to be used for sending and receiving
asynchronous requests.
|
abstract HttpClient.Builder |
followRedirects(HttpClient.Redirect policy) |
Specifies whether requests will automatically follow redirects issued
by the server.
|
abstract HttpClient.Builder |
pipelining(boolean enable) |
Enables pipelining mode for HTTP/1.1 requests sent through this
client.
|
abstract HttpClient.Builder |
priority(int priority) |
Sets the default priority for any HTTP/2 requests sent from this
client.
|
abstract HttpClient.Builder |
proxy(ProxySelector selector) |
Sets a
ProxySelector for this client. |
abstract HttpClient.Builder |
sslContext(SSLContext sslContext) |
Sets an SSLContext.
|
abstract HttpClient.Builder |
sslParameters(SSLParameters sslParameters) |
Sets an SSLParameters.
|
abstract HttpClient.Builder |
version(HttpClient.Version version) |
Requests a specific HTTP protocol version where possible.
|
public abstract HttpClient.Builder cookieManager(CookieManager manager)
manager
- the CookieManagerNullPointerException
- if manager
is nullpublic abstract HttpClient.Builder sslContext(SSLContext sslContext)
NetPermission
("setSSLContext")
The effect of not calling this method, is that a default SSLContext
is used, which is normally adequate for
client applications that do not need to specify protocols, or require
client authentication.
sslContext
- the SSLContextNullPointerException
- if sslContext
is nullSecurityException
- if a security manager is set and the
caller does not have any required permissionpublic abstract HttpClient.Builder sslParameters(SSLParameters sslParameters)
sslParameters
- the SSLParametersNullPointerException
- if sslParameters
is nullpublic abstract HttpClient.Builder executorService(ExecutorService s)
Executors.newCachedThreadPool
.s
- the ExecutorServiceNullPointerException
- if s
is nullpublic abstract HttpClient.Builder followRedirects(HttpClient.Redirect policy)
NEVER
policy
- the redirection policyNullPointerException
- if policy
is nullpublic abstract HttpClient.Builder version(HttpClient.Version version)
HttpClient.Version.HTTP_1_1
. If
HttpClient.Version.HTTP_2
is set, then each request will
attempt to upgrade to HTTP/2. If the upgrade succeeds, then the
response to this request will use HTTP/2 and all subsequent requests
and responses to the same
origin server
will use HTTP/2. If the upgrade fails, then the response will be
handled using HTTP/1.1
This setting can be over-ridden per request.
version
- the requested HTTP protocol versionNullPointerException
- if version
is nullpublic abstract HttpClient.Builder priority(int priority)
1
and 255
.priority
- the priority weightingIllegalArgumentException
- if the given priority is out of rangepublic abstract HttpClient.Builder pipelining(boolean enable)
enable
- true
enables pipeliningUnsupportedOperationException
- if pipelining mode is not
supported by this implementationpublic abstract HttpClient.Builder proxy(ProxySelector selector)
ProxySelector
for this client. If no selector
is set, then no proxies are used. If a null
parameter is
given then the system wide default proxy selector is used.ProxySelector.of(InetSocketAddress)
provides a ProxySelector which uses one proxy for all requests.selector
- the ProxySelectorpublic abstract HttpClient.Builder authenticator(Authenticator a)
a
- the Authenticatorpublic abstract HttpClient build()
HttpClient
built from the current state of this
builder. Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2016, Oracle and/or its affiliates. All rights reserved.
DRAFT 9-internal+0-2016-10-04-161205.jjg.dev.8159855.tools-spi