org.apache.commons.httpclient

Class ProxyClient


public class ProxyClient
extends Object

A client that provides sockets for communicating through HTTP proxies via the HTTP CONNECT method. This is primarily needed for non-HTTP protocols that wish to communicate via an HTTP proxy.
Since:
3.0

Nested Class Summary

static class
ProxyClient.ConnectResponse
Contains the method used to execute the connect along with the created socket.

Constructor Summary

ProxyClient()
Creates an instance of ProxyClient using default parameter set.
ProxyClient(HttpClientParams params)
Creates an instance of ProxyClient using the given parameter set.

Method Summary

ProxyClient.ConnectResponse
connect()
Creates a socket that is connected, via the HTTP CONNECT method, to a proxy.
HostConfiguration
getHostConfiguration()
Returns the host configuration associated with the ProxyClient.
HttpClientParams
getParams()
Returns HTTP protocol parameters associated with this ProxyClient.
HttpState
getState()
Returns HTTP state associated with the ProxyClient.
void
setHostConfiguration(HostConfiguration hostConfiguration)
Assigns the host configuration to use with the ProxyClient.
void
setParams(HttpClientParams params)
Assigns HTTP protocol parameters for this ProxyClient.
void
setState(HttpState state)
Assigns HTTP state for the ProxyClient.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

ProxyClient

public ProxyClient()
Creates an instance of ProxyClient using default parameter set.
Usages and Demos :

View More Examples of ProxyClient()
   1:         
   2:         ProxyClient proxyclient = new ProxyClient();
   3:         proxyclient.getHostConfiguration().setHost("www.yahoo.com");
   4:         proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);
   5:         proxyclient.getState().setProxyCredentials(

View Full Code Here

ProxyClient

public ProxyClient(HttpClientParams params)
Creates an instance of ProxyClient using the given parameter set.
Parameters:
params - The parameters to use.

Method Details

connect

public ProxyClient.ConnectResponse connect()
            throws IOException,
                   HttpException
Creates a socket that is connected, via the HTTP CONNECT method, to a proxy.

Even though HTTP CONNECT proxying is generally used for HTTPS tunneling, the returned socket will not have been wrapped in an SSL socket.

Both the proxy and destination hosts must be set via the host configuration prior to calling this method.

Returns:
the connect response
Usages and Demos :

View More Examples of connect()
   1: 
   2: import org.apache.commons.httpclient.ProxyClient;
   3: import org.apache.commons.httpclient.UsernamePasswordCredentials;
   4:         ...
   5:         
   6:         ProxyClient proxyclient = new ProxyClient();
   7:         proxyclient.getHostConfiguration().setHost("www.yahoo.com");
   8:         ...
   9:         
  10:         ProxyClient.ConnectResponse response = proxyclient.connect(); 
  11:         

View Full Code Here

getHostConfiguration

public HostConfiguration getHostConfiguration()
Returns the host configuration associated with the ProxyClient.
Usages and Demos :

View More Examples of getHostConfiguration()
   1: 
   2: import org.apache.commons.httpclient.ProxyClient;
   3: import org.apache.commons.httpclient.UsernamePasswordCredentials;
   4:         ...
   5:         
   6:         ProxyClient proxyclient = new ProxyClient();
   7:         ...
   8:         proxyclient.getHostConfiguration().setHost("www.yahoo.com");
   9:         ...
  10:         proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);

View Full Code Here

getParams

public HttpClientParams getParams()
Returns HTTP protocol parameters associated with this ProxyClient.

getState

public HttpState getState()
Returns HTTP state associated with the ProxyClient.
Returns:
the shared client state
Usages and Demos :

View More Examples of getState()
   1: 
   2: import org.apache.commons.httpclient.ProxyClient;
   3: import org.apache.commons.httpclient.UsernamePasswordCredentials;
   4:         ...
   5:         
   6:         ProxyClient proxyclient = new ProxyClient();
   7:         proxyclient.getHostConfiguration().setHost("www.yahoo.com");
   8:         ...
   9:         proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);
  10:         proxyclient.getState().setProxyCredentials(
  11:             new AuthScope("10.0.1.1", 3128, null),

View Full Code Here

setHostConfiguration

public void setHostConfiguration(HostConfiguration hostConfiguration)
Assigns the host configuration to use with the ProxyClient.
Parameters:
hostConfiguration - The host configuration to set

setParams

public void setParams(HttpClientParams params)
Assigns HTTP protocol parameters for this ProxyClient.

setState

public void setState(HttpState state)
Assigns HTTP state for the ProxyClient.
Parameters:
state - the new HTTP state for the client
See Also:
getState()