public class HttpClientBuilder extends Object
| Constructor and Description |
|---|
HttpClientBuilder() |
| Modifier and Type | Method and Description |
|---|---|
HttpClientBuilder |
authPreemprive(boolean pre)
Sets whether the resulting HttpClient should send authorization before
it's requested by the server.
|
HttpClientBuilder |
basicAuth(String username,
String password)
Turns on a Basic authentication.
|
HttpClientBuilder |
basicAuthHost(String host)
Constraints host for which Basic auth is sent.
|
HttpClientBuilder |
basicAuthPort(int port)
Constraints port for which Basic auth is sent.
|
org.apache.commons.httpclient.HttpClient |
build()
Builds the configured HttpClient.
|
static HttpClientBuilder |
create()
Creates a new builder.
|
HttpClientBuilder |
keyStore(URL url,
String password)
Configures a key store for the current SSL host (see
ssl(String)). |
HttpClientBuilder |
proxyHost(String host)
Sets proxy host.
|
HttpClientBuilder |
proxyPort(int port)
Sets proxy port.
|
HttpClientBuilder |
securePort(int port)
Configures secure port for the HTTPS for current host
(see
ssl(String)). |
HttpClientBuilder |
secureSchema(String schema)
Configures secure schema for the HTTPS for current host
(see
ssl(String)). |
HttpClientBuilder |
ssl(String host)
Begins SSL configuration for the given host.
|
HttpClientBuilder |
sslEnabledProtocols(String[] protocols)
Sets a list of enabled SSL protocols.
|
HttpClientBuilder |
timeouts(int connectionTimeout,
int soTimeout,
long connectionManagerTimeout)
Configures timeouts of the HttpClient being built.
|
HttpClientBuilder |
trustKeyStore(URL url,
String password)
Configures a trust store for the current SSL host (see
ssl(String)). |
public static HttpClientBuilder create()
public HttpClientBuilder proxyHost(String host)
host - proxy hostpublic HttpClientBuilder proxyPort(int port)
port - proxy portproxyHost(String)public HttpClientBuilder authPreemprive(boolean pre)
pre - whether to use auth preemptivebasicAuth(String, String)public HttpClientBuilder basicAuth(String username, String password)
username - username to sendpassword - password to sendbasicAuthHost(String),
basicAuthPort(int)public HttpClientBuilder basicAuthHost(String host)
host - host for which to send Basic auth (for others it will not
be sent)basicAuth(String, String)public HttpClientBuilder basicAuthPort(int port)
port - port for which to send Basic auth (for others it will not
be sent)basicAuth(String, String)public HttpClientBuilder ssl(String host)
trustKeyStore(URL, String),
keyStore(URL, String), secureSchema(String),
securePort(int)).
Allows to enable both server validation (by supplying keyStore) and
client authentication (by supplying trustKeyStore).host - host for which to enable SSLtrustKeyStore(URL, String),
keyStore(URL, String),
secureSchema(String),
securePort(int)public HttpClientBuilder sslEnabledProtocols(String[] protocols)
protocols - protocolspublic HttpClientBuilder trustKeyStore(URL url, String password)
ssl(String)). If set, SSL client authentication will be used
when connecting to that host (i.e. the client certificate will be sent).url - URL from which to obtain trust storepassword - trust store passwordssl(String),
keyStore(URL, String)public HttpClientBuilder keyStore(URL url, String password)
ssl(String)). If set, SSL server validation will be used (i.e.
the server certificate will be requested and validated).url - URL from which to obtain key storepassword - key store passwordssl(String),
trustKeyStore(URL, String)public HttpClientBuilder secureSchema(String schema)
ssl(String)).schema - secure schema (usually, this is "https")ssl(String)public HttpClientBuilder securePort(int port)
ssl(String)).port - secure port (if this method is not called, it's
defaulted to 443)ssl(String)public HttpClientBuilder timeouts(int connectionTimeout, int soTimeout, long connectionManagerTimeout)
connectionTimeout - time in millis for connection to
be establishedsoTimeout - SO timeout (millis)connectionManagerTimeout - time in millis for connection to
be obtained from connection managerpublic org.apache.commons.httpclient.HttpClient build()
Copyright © 2015. All Rights Reserved.