Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.commons.httpclient.HttpClient
public class HttpClient
extends java.lang.Object
HTTP state
and
one or more HTTP connections
, to which
HTTP methods
can be applied.
Constructor Summary | |
| |
| |
| |
|
Method Summary | |
int |
|
int |
|
int |
|
String |
|
HostConfiguration |
|
HttpConnectionManager |
|
HttpClientParams |
|
int |
|
HttpState |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
public HttpClient()
Creates an instance of HttpClient using defaultparameter set
.
- See Also:
HttpClientParams
public HttpClient(HttpConnectionManager httpConnectionManager)
Creates an instance of HttpClient with a user specifiedHTTP connection manager
.
- Parameters:
httpConnectionManager
- Theconnection manager
to use.
- Since:
- 2.0
public HttpClient(HttpClientParams params)
Creates an instance of HttpClient using the givenparameter set
.
- Parameters:
params
- Theparameters
to use.
- Since:
- 3.0
- See Also:
HttpClientParams
public HttpClient(HttpClientParams params, HttpConnectionManager httpConnectionManager)
Creates an instance of HttpClient with a user specifiedparameter set
andHTTP connection manager
.
- Parameters:
params
- Theparameters
to use.httpConnectionManager
- Theconnection manager
to use.
- Since:
- 3.0
public int executeMethod(HostConfiguration hostConfiguration, HttpMethod method) throws IOException, HttpException
Executes the givenHTTP method
using customhost configuration
.
- Parameters:
hostConfiguration
- Thehost configuration
to use.method
- theHTTP method
to execute.
- Returns:
- the method's response code
- Throws:
HttpException
- If a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
- Since:
- 2.0
public int executeMethod(HostConfiguration hostconfig, HttpMethod method, HttpState state) throws IOException, HttpException
Executes the givenHTTP method
using the given customhost configuration
with the given customHTTP state
.
- Parameters:
hostconfig
- Thehost configuration
to use.method
- theHTTP method
to execute.state
- theHTTP state
to use when executing the method. Ifnull
, the state returned bygetState()
will be used instead.
- Returns:
- the method's response code
- Throws:
HttpException
- If a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
- Since:
- 2.0
public int executeMethod(HttpMethod method) throws IOException, HttpException
Executes the givenHTTP method
.
- Parameters:
method
- theHTTP method
to execute.
- Returns:
- the method's response code
- Throws:
HttpException
- If a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
public String getHost()
Deprecated. use #getHostConfiguration()
Returns the default host.
- Returns:
- The default host.
public HostConfiguration getHostConfiguration()
Returns thehost configuration
associated with the HttpClient.
- Returns:
host configuration
- Since:
- 2.0
public HttpConnectionManager getHttpConnectionManager()
Returns theHTTP connection manager
associated with the HttpClient.
- Returns:
HTTP connection manager
- Since:
- 2.0
public HttpClientParams getParams()
ReturnsHTTP protocol parameters
associated with this HttpClient.
- Since:
- 3.0
- See Also:
HttpClientParams
public int getPort()
Deprecated. use #getHostConfiguration()
Returns the default port.
- Returns:
- The default port.
public HttpState getState()
ReturnsHTTP state
associated with the HttpClient.
- Returns:
- the shared client state
- See Also:
setState(HttpState)
public boolean isStrictMode()
Deprecated. Use
HttpClientParams.getParameter(String)
to exercise a more granular control over HTTP protocol strictness.Returns the value of the strict mode flag.
- Returns:
- true if strict mode is enabled, false otherwise
- See Also:
setStrictMode(boolean)
public void setConnectionTimeout(int newTimeoutInMilliseconds)
Deprecated. Use
HttpConnectionManagerParams.setConnectionTimeout(int)
,HttpConnectionManager.getParams()
.Sets the timeout until a connection is etablished. A value of zero means the timeout is not used. The default value is zero.
- Parameters:
newTimeoutInMilliseconds
- Timeout in milliseconds.
public void setHostConfiguration(HostConfiguration hostConfiguration)
Assigns thehost configuration
to use with the HttpClient.
- Parameters:
hostConfiguration
- Thehost configuration
to set
- Since:
- 2.0
public void setHttpConnectionFactoryTimeout(long timeout)
Deprecated. Use
HttpClientParams.setConnectionManagerTimeout(long)
,getParams()
Sets the timeout in milliseconds used when retrieving anHTTP connection
from theHTTP connection manager
.
- Parameters:
timeout
- the timeout in milliseconds
public void setHttpConnectionManager(HttpConnectionManager httpConnectionManager)
Assigns theHTTP connection manager
to use with the HttpClient.
- Parameters:
httpConnectionManager
- TheHTTP connection manager
to set
- Since:
- 2.0
public void setParams(HttpClientParams params)
AssignsHTTP protocol parameters
for this HttpClient.
- Since:
- 3.0
- See Also:
HttpClientParams
public void setState(HttpState state)
AssignsHTTP state
for the HttpClient.
- Parameters:
state
- the newHTTP state
for the client
- See Also:
getState()
public void setStrictMode(boolean strictMode)
Deprecated. Use
HttpClientParams.setParameter(String,Object)
to exercise a more granular control over HTTP protocol strictness.Defines how strictly the method follows the HTTP protocol specification (see RFC 2616 and other relevant RFCs). In the strict mode the method precisely implements the requirements of the specification, whereas in non-strict mode it attempts to mimic the exact behaviour of commonly used HTTP agents, which many HTTP servers expect.
- Parameters:
strictMode
- true for strict mode, false otherwise
- See Also:
isStrictMode()
public void setTimeout(int newTimeoutInMilliseconds)
Deprecated. Use
HttpConnectionManagerParams.setSoTimeout(int)
,HttpConnectionManager.getParams()
.Sets the socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data. A timeout value of zero is interpreted as an infinite timeout.
- Parameters:
newTimeoutInMilliseconds
- Timeout in milliseconds