|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.httpclient.HttpClient
An HTTP "user-agent", containing an HTTP state
and
one or more HTTP connections
, to which
HTTP methods
can be applied.
Constructor Summary | |
HttpClient()
Creates an instance of HttpClient using a simple HTTP connection manager . |
|
HttpClient(HttpConnectionManager httpConnectionManager)
Creates an instance of HttpClient with a user specified connection manager. |
Method Summary | |
(package private) static void |
|
void |
endSession()
Deprecated. this method has no effect. HttpMethod.releaseConnection()
should be used to release resources after a HttpMethod has been executed. |
int |
executeMethod(HostConfiguration hostConfiguration,
HttpMethod method)
Executes the given HTTP method using custom
host configuration . |
int |
executeMethod(HostConfiguration hostConfiguration,
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. |
int |
getPort()
Deprecated. use #getHostConfiguration() |
HttpState |
getState()
Returns HTTP state associated with the HttpClient. |
boolean |
isStrictMode()
Returns the value of the strict mode flag. |
void |
setConnectionTimeout(int newTimeoutInMilliseconds)
Sets the timeout until a connection is etablished. |
void |
setHostConfiguration(HostConfiguration hostConfiguration)
Assigns the host configuration to use with the
HttpClient. |
void |
setHttpConnectionFactoryTimeout(long timeout)
Sets the timeout in milliseconds used when retrieving an HTTP connection from the
HTTP connection manager . |
void |
setHttpConnectionManager(HttpConnectionManager httpConnectionManager)
Assigns the HTTP connection manager to use with
the HttpClient. |
void |
setState(HttpState state)
Assigns HTTP state for the HttpClient. |
void |
setStrictMode(boolean strictMode)
Defines how strictly the method follows the HTTP protocol specification (see RFC 2616 and other relevant RFCs). |
void |
setTimeout(int newTimeoutInMilliseconds)
Sets the socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data. |
void |
startSession(String host,
int port)
Deprecated. use HostConfiguration |
void |
startSession(String host,
int port,
boolean https)
Deprecated. use HostConfiguration |
void |
startSession(String host,
int port,
Credentials creds)
Deprecated. use HostConfiguration and HttpState |
void |
startSession(String host,
int port,
Credentials creds,
boolean https)
Deprecated. use HostConfiguration and HttpState |
void |
startSession(String host,
int port,
String proxyhost,
int proxyport)
Deprecated. use HostConfiguration |
void |
startSession(String host,
int port,
String proxyhost,
int proxyport,
boolean secure)
Deprecated. use HostConfiguration |
void |
startSession(URI uri)
Deprecated. use HostConfiguration |
void |
startSession(URL url)
Deprecated. use HostConfiguration |
void |
startSession(URL url,
Credentials creds)
Deprecated. use HostConfiguration and HttpState |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HttpClient()
simple HTTP connection manager
.SimpleHttpConnectionManager
public HttpClient(HttpConnectionManager httpConnectionManager)
httpConnectionManager
- The connection manager
to use.Method Detail |
static void()
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)
strictMode
- true for strict mode, false otherwiseisStrictMode()
public boolean isStrictMode()
setStrictMode(boolean)
public void setTimeout(int newTimeoutInMilliseconds)
newTimeoutInMilliseconds
- Timeout in millisecondspublic void setHttpConnectionFactoryTimeout(long timeout)
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 void startSession(String host, int port)
HostConfiguration
host
- the host to connect toport
- the port to connect togetHostConfiguration()
public void startSession(String host, int port, boolean https)
HostConfiguration
host
- the host to connect toport
- the port to connect tohttps
- when true
, create an HTTPS sessiongetHostConfiguration()
public void startSession(String host, int port, Credentials creds)
HostConfiguration
and HttpState
host
- the host to connect toport
- the port to connect tocreds
- the default credentials to usegetHostConfiguration()
,
getState()
,
startSession(String, int, Credentials, boolean)
public void startSession(String host, int port, Credentials creds, boolean https)
HostConfiguration
and HttpState
host
- the host to connect toport
- the port to connect tocreds
- the default credentials to usehttps
- when true
, create an HTTPS sessiongetHostConfiguration()
,
getState()
public void startSession(URI uri) throws URIException, IllegalStateException
HostConfiguration
Note that the path component is not utilized.
uri
- an HttpURL
or HttpsURL
instance; the
URI
from which the scheme, userinfo, host and port of the
session are determinedIllegalStateException
- not enough information to processURIException
- If the URI is bad.getHostConfiguration()
public void startSession(URL url) throws IllegalArgumentException
HostConfiguration
Note that everything but the protocol, host and port of the given url is ignored.
url
- the URL
from which the protocol, host, and port of
the session are determinedIllegalArgumentException
- if the protocol is not http or httpsgetHostConfiguration()
public void startSession(URL url, Credentials creds) throws IllegalArgumentException
HostConfiguration
and HttpState
Note that everything but the protocol, host and port of the given url is ignored.
url
- the URL
from which the protocol, host, and port of
the session are determinedcreds
- the default credentials to useIllegalArgumentException
- if the protocol is not http or httpsgetHostConfiguration()
,
getState()
public void startSession(String host, int port, String proxyhost, int proxyport)
HostConfiguration
host
- the host to connect toport
- the port to connect toproxyhost
- the proxy host to connect viaproxyport
- the proxy port to connect viagetHostConfiguration()
public void startSession(String host, int port, String proxyhost, int proxyport, boolean secure)
HostConfiguration
host
- the host to connect toport
- the port to connect toproxyhost
- the proxy host to connect viaproxyport
- the proxy port to connect viasecure
- whether or not to connect using HTTPSgetHostConfiguration()
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.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, HttpState state) throws IOException, HttpException
HTTP method
using the given custom
host configuration
with the given custom
HTTP state
.hostConfiguration
- The host configuration
to use.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 instead.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 void endSession() throws IOException
HttpMethod.releaseConnection()
should be used to release resources after a HttpMethod has been executed.
HttpMethod.releaseConnection()
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 set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |