org.apache.commons.httpclient
Class HttpMultiClient

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

public class HttpMultiClient
extends java.lang.Object

An Http user-agent that supports multiple connections to Http servers.

Author:
Marc A. Saegesser, Sean C. Sullivan
See Also:
HttpClient

Constructor Summary
HttpMultiClient()
          No-args constructor.
HttpMultiClient(java.lang.String proxyHost, int proxyPort)
          Constructor that uses proxy host and port.
 
Method Summary
 int executeMethod(HttpUrlMethod method)
          Execute the given HttpUrlMethod using my current connection and HttpState.
 int getConnectionTimeout()
          Returns the value of connection timeout.
 java.lang.String getProxyHost()
          Returns the hostname for the HTTP proxy server in use for all requests.
 int getProxyPort()
          Returns the HTTP proxy server port number
 int getRequestTimeout()
          Returns the value of the request timeout.
 HttpSharedState getState()
          Get the shared state
 boolean isStrictMode()
           
 void setConnectionTimeout(int timeout)
          Sets the connection timeout.
 void setProxyHost(java.lang.String host)
          Sets the hostname for the HTTP proxy server to use for all requests.
 void setProxyPort(int port)
          Sets the port number for the HTTP proxy server to use for all requests.
 void setRequestTimeout(int timeout)
          Sets the request timeout.
 void setSSLSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)
          Specifies an alternative factory for SSL sockets.
 void setState(HttpSharedState state)
          Set the shared state.
 void setStrictMode(boolean strictMode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpMultiClient

public HttpMultiClient()
No-args constructor. HttpMultiClient objects will have strictMode enabled by default.

HttpMultiClient

public HttpMultiClient(java.lang.String proxyHost,
                       int proxyPort)
Constructor that uses proxy host and port. Strict mode is enabled by default.
Parameters:
proxyHost - host name of the proxy server to use
proxyPort - port number of the proxy server to use
Method Detail

setState

public void setState(HttpSharedState state)
Set the shared state.
Parameters:
state - the new shared state
See Also:
getState()

getState

public HttpSharedState getState()
Get the shared state
Returns:
the shared state
See Also:
setState(HttpSharedState)

setStrictMode

public void setStrictMode(boolean strictMode)
Parameters:
strictMode - true if strict mode should be used
See Also:
isStrictMode()

isStrictMode

public boolean isStrictMode()
Returns:
true if strict mode being used
See Also:
setStrictMode(boolean)

setConnectionTimeout

public void setConnectionTimeout(int timeout)
Sets the connection timeout. The connection timeout is how long (in milliseconds) HttpMultiClient will block in executeMethod waiting for a connection to the requested server to become available.
Setting the connection timeout to 0 will cause executeMethod() to block indefinitely (this is the default behaviour).
Parameters:
timeout - the time, in milliseconds, to block waiting for an available connection
See Also:
getConnectionTimeout(), executeMethod(org.apache.commons.httpclient.HttpUrlMethod)

getConnectionTimeout

public int getConnectionTimeout()
Returns the value of connection timeout.
Returns:
the connection timeout value
See Also:
setConnectionTimeout(int)

setRequestTimeout

public void setRequestTimeout(int timeout)
Sets the request timeout. The executeMethod method calls HttpConnection.setSoTimeout() with this value before executing the request.
Parameters:
timeout - the SoTimeout value, in milliseconds
See Also:
getRequestTimeout(), HttpConnection.setSoTimeout(int)

getRequestTimeout

public int getRequestTimeout()
Returns the value of the request timeout.
Returns:
the request timeout
See Also:
setRequestTimeout

setProxyHost

public void setProxyHost(java.lang.String host)
Sets the hostname for the HTTP proxy server to use for all requests.
Parameters:
host - The hostname of the HTTP proxy server
See Also:
HttpConnectionManager.setProxyHost(java.lang.String)

getProxyHost

public java.lang.String getProxyHost()
Returns the hostname for the HTTP proxy server in use for all requests.
Returns:
the hostname of the HTTP proxy server
See Also:
HttpConnectionManager.getProxyHost()

setProxyPort

public void setProxyPort(int port)
Sets the port number for the HTTP proxy server to use for all requests.
Parameters:
port - the proxy server port number
See Also:
HttpConnectionManager.setProxyPort(int)

setSSLSocketFactory

public void setSSLSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)
Specifies an alternative factory for SSL sockets.
Parameters:
sslSocketFactory - a living instance of the alternative SSLSocketFactory
See Also:
HttpConnection setSSLSocketFactory

getProxyPort

public int getProxyPort()
Returns the HTTP proxy server port number
Returns:
the HTTP proxy server port number
See Also:
HttpConnectionManager.getProxyPort()

executeMethod

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


Copyright (c) 2001 - Apache Software Foundation