org.apache.commons.httpclient
Class ConnectMethod

java.lang.Object
  |
  +--org.apache.commons.httpclient.HttpMethodBase
        |
        +--org.apache.commons.httpclient.ConnectMethod
All Implemented Interfaces:
HttpMethod

public class ConnectMethod
extends HttpMethodBase

Wraps another method to tunnel through a proxy.

Since:
2.0
Version:
$Revision: 1.18.2.3 $ $Date: 2004/06/25 03:27:40 $
Author:
Ortwin Gl???ck, dIon Gillard, Mike Bowler, Oleg Kalnichevski

Field Summary
static String NAME
          the name of this method
 
Fields inherited from class org.apache.commons.httpclient.HttpMethodBase
USER_AGENT
 
Constructor Summary
ConnectMethod(HttpMethod method)
          Create a connect method wrapping the existing method
 
Method Summary
protected  void addAuthorizationRequestHeader(HttpState state, HttpConnection conn)
          This method does nothing.
protected  void addContentLengthRequestHeader(HttpState state, HttpConnection conn)
          This method does nothing.
protected  void addCookieRequestHeader(HttpState state, HttpConnection conn)
          This method does nothing.
protected  void addRequestHeaders(HttpState state, HttpConnection conn)
          Populates the request headers map to with additional headers to be submitted to the given HttpConnection.
 int execute(HttpState state, HttpConnection conn)
          Execute this method by tunnelling and then executing the wrapped method.
 String getName()
          Provide the name of this method.
protected  boolean shouldCloseConnection(HttpConnection conn)
          Returns true if the status code is anything other than SC_OK, false otherwise.
protected  void writeRequestLine(HttpState state, HttpConnection conn)
          Special Connect request.
 
Methods inherited from class org.apache.commons.httpclient.HttpMethodBase
, addHostRequestHeader, addProxyAuthorizationRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, fakeResponse, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getFollowRedirects, getHostConfiguration, getMethodRetryHandler, getPath, getProxyAuthenticationRealm, getQueryString, getRecoverableExceptionCount, getRequestCharSet, getRequestContentLength, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isConnectionCloseForced, isHttp11, isStrictMode, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseBody, readResponseHeaders, readStatusLine, recycle, releaseConnection, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setFollowRedirects, setHostConfiguration, setHttp11, setMethodRetryHandler, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, validate, writeRequest, writeRequestBody, writeRequestHeaders
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final String NAME
the name of this method
Constructor Detail

ConnectMethod

public ConnectMethod(HttpMethod method)
Create a connect method wrapping the existing method
Parameters:
method - the method to execute after connecting to the server
Method Detail

getName

public String getName()
Provide the name of this method.
Overrides:
getName in class HttpMethodBase
Returns:
the String "CONNECT"

addAuthorizationRequestHeader

protected void addAuthorizationRequestHeader(HttpState state,
                                             HttpConnection conn)
                                      throws IOException,
                                             HttpException
This method does nothing. CONNECT request is not supposed to contain Authorization request header.
Overrides:
addAuthorizationRequestHeader in class HttpMethodBase
Parameters:
state - current state of http requests
conn - the connection to use for I/O
Throws:
IOException - when errors occur reading or writing to/from the connection
HttpException - when a recoverable error occurs
See Also:
HttpMethodBase.addAuthorizationRequestHeader(HttpState, HttpConnection)

addContentLengthRequestHeader

protected void addContentLengthRequestHeader(HttpState state,
                                             HttpConnection conn)
                                      throws IOException,
                                             HttpException
This method does nothing. CONNECT request is not supposed to contain Content-Length request header.
Overrides:
addContentLengthRequestHeader in class HttpMethodBase
Parameters:
state - current state of http requests
conn - the connection to use for I/O
Throws:
IOException - when errors occur reading or writing to/from the connection
HttpException - when a recoverable error occurs
See Also:
HttpMethodBase.addContentLengthRequestHeader(HttpState, HttpConnection)

addCookieRequestHeader

protected void addCookieRequestHeader(HttpState state,
                                      HttpConnection conn)
                               throws IOException,
                                      HttpException
This method does nothing. CONNECT request is not supposed to contain Cookie request header.
Overrides:
addCookieRequestHeader in class HttpMethodBase
Parameters:
state - current state of http requests
conn - the connection to use for I/O
Throws:
IOException - when errors occur reading or writing to/from the connection
HttpException - when a recoverable error occurs
See Also:
HttpMethodBase.addCookieRequestHeader(HttpState, HttpConnection)

addRequestHeaders

protected void addRequestHeaders(HttpState state,
                                 HttpConnection conn)
                          throws IOException,
                                 HttpException
Populates the request headers map to with additional headers to be submitted to the given HttpConnection.

This implementation adds User-Agent, Host, and Proxy-Authorization headers, when appropriate.

Overrides:
addRequestHeaders in class HttpMethodBase
Parameters:
state - the client state
conn - the HttpConnection the headers will eventually be written to
Throws:
IOException - when an error occurs writing the request
HttpException - when a HTTP protocol error occurs
See Also:
HttpMethodBase.writeRequestHeaders(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)

execute

public int execute(HttpState state,
                   HttpConnection conn)
            throws IOException,
                   HttpException
Execute this method by tunnelling and then executing the wrapped method.
Overrides:
execute in class HttpMethodBase
Parameters:
state - the current http state
conn - the connection to write to
Returns:
the http status code from execution
Throws:
HttpException - when an error occurs writing the headers
IOException - when an error occurs writing the headers

writeRequestLine

protected void writeRequestLine(HttpState state,
                                HttpConnection conn)
                         throws IOException,
                                HttpException
Special Connect request.
Overrides:
writeRequestLine in class HttpMethodBase
Parameters:
state - the current http state
conn - the connection to write to
Throws:
IOException - when an error occurs writing the request
HttpException - when an error occurs writing the request

shouldCloseConnection

protected boolean shouldCloseConnection(HttpConnection conn)
Returns true if the status code is anything other than SC_OK, false otherwise.
Overrides:
shouldCloseConnection in class HttpMethodBase
Parameters:
conn - the connection to test
Returns:
true if the connection should be closed
See Also:
HttpMethodBase.shouldCloseConnection(HttpConnection), HttpStatus.SC_OK


Copyright © 2001-2004 Apache Software Foundation. All Rights Reserved.