org.apache.commons.httpclient
Class HttpClient

java.lang.Object
  |
  +--org.apache.commons.httpclient.HttpClient

public class HttpClient
extends java.lang.Object

An HTTP "user-agent", containing an HttpState and one or more HttpConnections, to which HttpMethods can be applied.

Version:
$Revision: 1.40 $ $Date: 2001/10/06 00:46:42 $
Author:
Remy Maucherat, Rodney Waldhoff

Constructor Summary
HttpClient()
          Constructor.
 
Method Summary
 void endSession()
          End the current session, closing my the associated connection if any.
 int executeMethod(HttpMethod method)
          Execute the given HttpMethod using my current connection and HttpState.
 HttpState getState()
          Get my state.
 void setState(HttpState state)
          Set my state.
 void startSession(java.lang.String host, int port)
          Start an HTTP session with the server at the given host and port.
 void startSession(java.lang.String host, int port, boolean https)
          Start an HTTP or HTTPS session with the server at the given host and port.
 void startSession(java.lang.String host, int port, Credentials creds)
          Start an HTTP session with the server at the given host and port using the given default default credentials.
 void startSession(java.lang.String host, int port, Credentials creds, boolean https)
          Start an HTTP or HTTPS session with the server at the given host and port using the given default default credentials.
 void startSession(java.lang.String host, int port, java.lang.String proxyhost, int proxyport)
          Start an HTTP session with the server specified by the given host and port via the given proxyhost and proxyport.
 void startSession(java.net.URL url)
          Start an HTTP or HTTPS session with the server specified by the protocol, host and port of the given url.
 void startSession(java.net.URL url, Credentials creds)
          Start an HTTP or HTTPS session with the server specified by the protocol, host and port of the given url, using the given credentials by default.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpClient

public HttpClient()
Constructor.
Method Detail

getState

public HttpState getState()
Get my state.

setState

public void setState(HttpState state)
Set my state.

startSession

public void startSession(java.lang.String host,
                         int port)
Start an HTTP session with the server at the given host and port.
Parameters:
host - the host to connect to
port - the port to connect to

startSession

public void startSession(java.lang.String host,
                         int port,
                         boolean https)
Start an HTTP or HTTPS session with the server at the given host and port.
Parameters:
host - the host to connect to
port - the port to connect to
https - when true, create an HTTPS session

startSession

public void startSession(java.lang.String host,
                         int port,
                         Credentials creds)
Start an HTTP session with the server at the given host and port using the given default default credentials.
Parameters:
host - the host to connect to
port - the port to connect to
creds - the default credentials to use

startSession

public void startSession(java.lang.String host,
                         int port,
                         Credentials creds,
                         boolean https)
Start an HTTP or HTTPS session with the server at the given host and port using the given default default credentials.
Parameters:
host - the host to connect to
port - the port to connect to
creds - the default credentials to use
https - when true, create an HTTPS session

startSession

public void startSession(java.net.URL url)
Start an HTTP or HTTPS session with the server specified by the protocol, host and port of the given url.

Note that everything but the protocol, host and port of the given url is ignored.

Parameters:
url - the URL from which the protocol, host, and port of the session are determined

startSession

public void startSession(java.net.URL url,
                         Credentials creds)
Start an HTTP or HTTPS session with the server specified by the protocol, host and port of the given url, using the given credentials by default.

Note that everything but the protocol, host and port of the given url is ignored.

Parameters:
creds - the default credentials to use
url - the URL from which the protocol, host, and port of the session are determined

startSession

public void startSession(java.lang.String host,
                         int port,
                         java.lang.String proxyhost,
                         int proxyport)
Start an HTTP session with the server specified by the given host and port via the given proxyhost and proxyport.
Parameters:
host - the host to connect to
port - the port to connect to
proxyhost - the proxy host to connect via
proxyport - the proxy port to connect via

executeMethod

public int executeMethod(HttpMethod method)
                  throws java.io.IOException,
                         HttpException
Execute the given HttpMethod using my current connection and HttpState.
Parameters:
method - the HttpMethod to execute
Returns:
the method's response code
Throws:
java.io.IOException - if an I/O error occurs
HttpException - if a protocol exception occurs

endSession

public void endSession()
                throws java.io.IOException
End the current session, closing my the associated connection if any.


Copyright (c) 2001 - Apache Software Foundation