@NotThreadSafe public class HttpClientBuilder extends Object
HttpClient
s.
This builder will produce clients that employ the MultiThreadedHttpConnectionManager
and as such users of the
clients MUST be sure to invoke org.apache.commons.httpclient.HttpMethod#releaseConnection()
after they have
finished with the method.Constructor and Description |
---|
HttpClientBuilder()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
HttpClient |
buildClient()
Builds an HTTP client with the given settings.
|
int |
getConnectionRetryAttempts()
Gets the number of times a connection will be tried if a host is unreachable.
|
int |
getConnectionTimeout()
Gets the time, in milliseconds, to wait for connection establishments.
|
String |
getContentCharSet()
Gets the character set used for HTTP content.
|
SecureProtocolSocketFactory |
getHttpsProtocolSocketFactory()
Gets the protocol socket factory used for the https scheme.
|
int |
getMaxConnectionsPerHost()
Gets the maximum number of connections, per host, that the client will create.
|
int |
getMaxTotalConnections()
Gets the maximum number of total connections the client will create.
|
String |
getProxyHost()
Gets the host name of the HTTP proxy server through which connections will be made.
|
String |
getProxyPassword()
Gets the password used to connect to the HTTP proxy server.
|
int |
getProxyPort()
Gets the port of the HTTP proxy server through which connections will be made.
|
String |
getProxyUsername()
Gets the username used to connect to the HTTP proxy server.
|
int |
getReceiveBufferSize()
Gets the size of buffer, in bytes, used when receiving content.
|
int |
getSendBufferSize()
Gets the size of buffer, in bytes, used when sending content.
|
boolean |
isPreemptiveAuthentication()
Gets whether authentication is performed preemptively.
|
boolean |
isTcpNoDelay()
Gets whether to use TCP No Delay when sending data.
|
void |
resetDefaults()
Resets the builder to its default values.
|
void |
setConnectionRetryAttempts(int attempts)
Sets the number of times a connection will be tried if a host is unreachable.
|
void |
setConnectionTimeout(int timeout)
Sets the time, in milliseconds, to wait for connection establishments.
|
void |
setContentCharSet(String charSet)
Sets the character set used for HTTP content.
|
void |
setHttpsProtocolSocketFactory(SecureProtocolSocketFactory factory)
Sets the protocol socket factory used for the https scheme.
|
void |
setMaxConnectionsPerHost(int max)
Sets the maximum number of connections, per host, that the client will create.
|
void |
setMaxTotalConnections(int max)
Sets the maximum number of total connections the client will create.
|
void |
setPreemptiveAuthentication(boolean preemptive)
Sets whether authentication is performed preemptively.
|
void |
setProxyHost(String host)
Sets the host name of the HTTP proxy server through which connections will be made.
|
void |
setProxyPassword(String password)
Sets the password used to connect to the HTTP proxy server.
|
void |
setProxyPort(int port)
Sets the port of the HTTP proxy server through which connections will be made.
|
void |
setProxyUsername(String username)
Sets the username used to connect to the HTTP proxy server.
|
void |
setReceiveBufferSize(int size)
Sets the size of buffer, in bytes, used when sending content.
|
void |
setSendBufferSize(int size)
Sets the size of buffer, in bytes, used when sending content.
|
void |
setTcpNoDelay(boolean noDelay)
Sets whether to use TCP No Delay when sending data.
|
public void resetDefaults()
public HttpClient buildClient()
public String getProxyHost()
public void setProxyHost(String host)
host
- host name of the HTTP proxy server through which connections will be madepublic int getProxyPort()
public void setProxyPort(int port)
port
- port of the HTTP proxy server through which connections will be madepublic String getProxyUsername()
public void setProxyUsername(String username)
username
- username used to connect to the HTTP proxy serverpublic String getProxyPassword()
public void setProxyPassword(String password)
password
- password used to connect to the HTTP proxy serverpublic boolean isPreemptiveAuthentication()
false
.public void setPreemptiveAuthentication(boolean preemptive)
preemptive
- whether authentication is performed preemptivelypublic String getContentCharSet()
UTF-8
.public void setContentCharSet(String charSet)
charSet
- character set used for HTTP contentpublic int getConnectionTimeout()
public void setConnectionTimeout(int timeout)
timeout
- time, in milliseconds, to wait for connection establishmentspublic int getSendBufferSize()
public void setSendBufferSize(int size)
size
- size of buffer, in bytes, used when sending contentpublic int getReceiveBufferSize()
public void setReceiveBufferSize(int size)
size
- size of buffer, in bytes, used when sending contentpublic boolean isTcpNoDelay()
true
.public void setTcpNoDelay(boolean noDelay)
noDelay
- whether to use TCP No Delay when sending datapublic int getMaxConnectionsPerHost()
public void setMaxConnectionsPerHost(int max)
max
- maximum number of connections, per host, that the client will createpublic int getMaxTotalConnections()
public void setMaxTotalConnections(int max)
max
- maximum number of total connections the client will create, must be greater than zeropublic int getConnectionRetryAttempts()
public void setConnectionRetryAttempts(int attempts)
attempts
- number of times a connection will be tried if a host is unreachablepublic SecureProtocolSocketFactory getHttpsProtocolSocketFactory()
public void setHttpsProtocolSocketFactory(SecureProtocolSocketFactory factory)
factory
- the httpsProtocolSocketFactory to setCopyright © 2014 JBoss by Red Hat. All Rights Reserved.