public class HttpClient extends Object
An HTTP "user-agent", containing an HTTP state
and
one or more HTTP connections
, to which
HTTP methods
can be applied.
Constructor and Description |
---|
HttpClient()
Creates an instance of HttpClient using default
parameter set . |
HttpClient(HttpClientParams params)
Creates an instance of HttpClient using the given
parameter set . |
HttpClient(HttpClientParams params,
HttpConnectionManager httpConnectionManager)
Creates an instance of HttpClient with a user specified
parameter set and
HTTP connection manager . |
HttpClient(HttpConnectionManager httpConnectionManager)
Creates an instance of HttpClient with a user specified
HTTP connection manager . |
Modifier and Type | Method and Description |
---|---|
int |
executeMethod(HostConfiguration hostConfiguration,
HttpMethod method)
Executes the given
HTTP method using custom
host configuration . |
int |
executeMethod(HostConfiguration hostconfig,
HttpMethod method,
HttpState state)
Executes the given
HTTP method using the given custom
host configuration with the given custom
HTTP state . |
int |
executeMethod(HttpMethod method)
Executes the given
HTTP method . |
String |
getHost()
Deprecated.
use #getHostConfiguration()
|
HostConfiguration |
getHostConfiguration()
Returns the
host configuration associated with the
HttpClient. |
HttpConnectionManager |
getHttpConnectionManager()
Returns the
HTTP connection manager associated
with the HttpClient. |
HttpClientParams |
getParams()
Returns
HTTP protocol parameters associated with this HttpClient. |
int |
getPort()
Deprecated.
use #getHostConfiguration()
|
HttpState |
getState()
Returns
HTTP state associated with the HttpClient. |
boolean |
isStrictMode()
Deprecated.
Use
DefaultHttpParams.getParameter(String)
to exercise a more granular control over HTTP protocol strictness. |
void |
setConnectionTimeout(int newTimeoutInMilliseconds)
|
void |
setHostConfiguration(HostConfiguration hostConfiguration)
Assigns the
host configuration to use with the
HttpClient. |
void |
setHttpConnectionFactoryTimeout(long timeout)
Deprecated.
|
void |
setHttpConnectionManager(HttpConnectionManager httpConnectionManager)
Assigns the
HTTP connection manager to use with
the HttpClient. |
void |
setParams(HttpClientParams params)
Assigns
HTTP protocol parameters for this HttpClient. |
void |
setState(HttpState state)
Assigns
HTTP state for the HttpClient. |
void |
setStrictMode(boolean strictMode)
Deprecated.
Use
DefaultHttpParams.setParameter(String, Object)
to exercise a more granular control over HTTP protocol strictness. |
void |
setTimeout(int newTimeoutInMilliseconds)
Deprecated.
|
public HttpClient()
parameter set
.HttpClientParams
public HttpClient(HttpClientParams params)
parameter set
.params
- The parameters
to use.HttpClientParams
public HttpClient(HttpClientParams params, HttpConnectionManager httpConnectionManager)
parameter set
and
HTTP connection manager
.params
- The parameters
to use.httpConnectionManager
- The connection manager
to use.public HttpClient(HttpConnectionManager httpConnectionManager)
HTTP connection manager
.httpConnectionManager
- The connection manager
to use.public HttpState getState()
HTTP state
associated with the HttpClient.setState(HttpState)
public void setState(HttpState state)
HTTP state
for the HttpClient.state
- the new HTTP state
for the clientgetState()
public void setStrictMode(boolean strictMode)
DefaultHttpParams.setParameter(String, Object)
to exercise a more granular control over HTTP protocol strictness.strictMode
- true for strict mode, false otherwiseisStrictMode()
public boolean isStrictMode()
DefaultHttpParams.getParameter(String)
to exercise a more granular control over HTTP protocol strictness.setStrictMode(boolean)
public void setTimeout(int newTimeoutInMilliseconds)
HttpConnectionParams.setSoTimeout(int)
,
HttpConnectionManager.getParams()
.newTimeoutInMilliseconds
- Timeout in millisecondspublic void setHttpConnectionFactoryTimeout(long timeout)
HttpClientParams.setConnectionManagerTimeout(long)
,
getParams()
HTTP connection
from the
HTTP connection manager
.timeout
- the timeout in millisecondsHttpConnectionManager.getConnection(HostConfiguration, long)
public void setConnectionTimeout(int newTimeoutInMilliseconds)
newTimeoutInMilliseconds
- Timeout in milliseconds.HttpConnection.setConnectionTimeout(int)
public int executeMethod(HttpMethod method) throws IOException, HttpException
HTTP method
.method
- the HTTP method
to execute.IOException
- If an I/O (transport) error occurs. Some transport exceptions
can be recovered from.HttpException
- If a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.public int executeMethod(HostConfiguration hostConfiguration, HttpMethod method) throws IOException, HttpException
HTTP method
using custom
host configuration
.hostConfiguration
- The host configuration
to use.
If null
, the host configuration returned by getHostConfiguration()
will be used.method
- the HTTP method
to execute.IOException
- If an I/O (transport) error occurs. Some transport exceptions
can be recovered from.HttpException
- If a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.public int executeMethod(HostConfiguration hostconfig, HttpMethod method, HttpState state) throws IOException, HttpException
HTTP method
using the given custom
host configuration
with the given custom
HTTP state
.hostconfig
- The host configuration
to use.
If null
, the host configuration returned by getHostConfiguration()
will be used.method
- the HTTP method
to execute.state
- the HTTP state
to use when executing the method.
If null
, the state returned by getState()
will be used.IOException
- If an I/O (transport) error occurs. Some transport exceptions
can be recovered from.HttpException
- If a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.public String getHost()
public int getPort()
public HostConfiguration getHostConfiguration()
host configuration
associated with the
HttpClient.host configuration
public void setHostConfiguration(HostConfiguration hostConfiguration)
host configuration
to use with the
HttpClient.hostConfiguration
- The host configuration
to setpublic HttpConnectionManager getHttpConnectionManager()
HTTP connection manager
associated
with the HttpClient.HTTP connection manager
public void setHttpConnectionManager(HttpConnectionManager httpConnectionManager)
HTTP connection manager
to use with
the HttpClient.httpConnectionManager
- The HTTP connection manager
to setpublic HttpClientParams getParams()
HTTP protocol parameters
associated with this HttpClient.HttpClientParams
public void setParams(HttpClientParams params)
HTTP protocol parameters
for this HttpClient.HttpClientParams
Copyright © 2010 - 2020 Adobe. All Rights Reserved