org.apache.commons.httpclient

Class ConnectMethod

Implemented Interfaces:
HttpMethod

public class ConnectMethod
extends HttpMethodBase

Establishes a tunneled HTTP connection via the CONNECT method.

Version:
$Revision: 155418 $ $Date: 2005-02-26 08:01:52 -0500 (Sat, 26 Feb 2005) $

Authors:
Ortwin Gl???ck
dIon Gillard
Mike Bowler
Oleg Kalnichevski

Since:
2.0

Field Summary

static String
NAME
the name of this method

Constructor Summary

ConnectMethod()
Create a connect method.
ConnectMethod(HttpMethod method)
Deprecated. the wrapped method is no longer used Create a connect method wrapping the existing method

Method Summary

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 and create a tunneled HttpConnection.
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

abort, addCookieRequestHeader, addHostRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addRequestHeaders, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getEffectiveVersion, getFollowRedirects, getHostAuthState, getHostConfiguration, getMethodRetryHandler, getName, getParams, getPath, getProxyAuthState, getProxyAuthenticationRealm, getQueryString, getRecoverableExceptionCount, getRequestCharSet, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getRequestHeaders, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isAborted, isConnectionCloseForced, isHttp11, isRequestSent, isStrictMode, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseBody, readResponseHeaders, readStatusLine, recycle, releaseConnection, removeRequestHeader, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setFollowRedirects, setHostConfiguration, setHttp11, setMethodRetryHandler, setParams, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, setURI, shouldCloseConnection, validate, writeRequest, writeRequestBody, writeRequestHeaders, writeRequestLine

Field Details

NAME

public static final String NAME
the name of this method

Constructor Details

ConnectMethod

public ConnectMethod()
Create a connect method.

Since:
3.0


ConnectMethod

public ConnectMethod(HttpMethod method)

Deprecated. the wrapped method is no longer used Create a connect method wrapping the existing method

Parameters:
method - the method to execute after connecting to the server

Method Details

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 interface HttpMethodBase

Parameters:
state - current state of http requests
conn - the connection to use for I/O

Throws:
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 interface HttpMethodBase

Parameters:
state - the client state
conn - the HttpConnection the headers will eventually be written to

Throws:
HttpException - when a HTTP protocol error occurs

See Also:
ConnectMethod


execute

public int execute(HttpState state,
                   HttpConnection conn)
            throws IOException,
                   HttpException
Execute this method and create a tunneled HttpConnection. If the method is successful (i.e. the status is a 2xx) tunnelCreated() will be called on the connection.
Specified by:
execute in interface HttpMethod
Overrides:
execute in interface 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

See Also:
HttpConnection.tunnelCreated()


getName

public String getName()
Provide the name of this method.
Specified by:
getName in interface HttpMethod
Overrides:
getName in interface HttpMethodBase

Returns:
the String "CONNECT"


shouldCloseConnection

protected boolean shouldCloseConnection(HttpConnection conn)
Returns true if the status code is anything other than SC_OK, false otherwise.
Overrides:
shouldCloseConnection in interface HttpMethodBase

Returns:
true if the connection should be closed

See Also:
HttpMethodBase.shouldCloseConnection(HttpConnection), HttpStatus.SC_OK


writeRequestLine

protected void writeRequestLine(HttpState state,
                                HttpConnection conn)
            throws IOException,
                   HttpException
Special Connect request.
Overrides:
writeRequestLine in interface HttpMethodBase

Parameters:
state - the current http state
conn - the connection to write to

Throws:
HttpException - when an error occurs writing the request


Copyright (c) 1999-2005 - Apache Software Foundation