org.apache.commons.httpclient

Class ConnectMethod

public class ConnectMethod extends HttpMethodBase

Establishes a tunneled HTTP connection via the CONNECT method.

Since: 2.0

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

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

Field Summary
static StringNAME
the name of this method
Constructor Summary
ConnectMethod()
Create a connect method.
ConnectMethod(HttpMethod method)
Method Summary
protected voidaddCookieRequestHeader(HttpState state, HttpConnection conn)
This method does nothing.
protected voidaddRequestHeaders(HttpState state, HttpConnection conn)
Populates the request headers map to with additional {@link Header headers} to be submitted to the given {@link HttpConnection}.
intexecute(HttpState state, HttpConnection conn)
Execute this method and create a tunneled HttpConnection.
StringgetName()
Provide the {@link #NAME name} of this method.
protected booleanshouldCloseConnection(HttpConnection conn)
Returns true if the status code is anything other than SC_OK, false otherwise.
protected voidwriteRequestLine(HttpState state, HttpConnection conn)
Special Connect request.

Field Detail

NAME

public static final String NAME
the name of this method

Constructor Detail

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 {@link HttpMethod method} to execute after connecting to the server

Method Detail

addCookieRequestHeader

protected void addCookieRequestHeader(HttpState state, HttpConnection conn)
This method does nothing. CONNECT request is not supposed to contain Cookie request header.

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

addRequestHeaders

protected void addRequestHeaders(HttpState state, HttpConnection conn)
Populates the request headers map to with additional {@link Header headers} to be submitted to the given {@link HttpConnection}.

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

Parameters: state the client state conn the {@link 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: ConnectMethod

execute

public int execute(HttpState state, HttpConnection conn)
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.

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

See Also: tunnelCreated

getName

public String getName()
Provide the {@link #NAME name} of this method.

Returns: the String "CONNECT"

shouldCloseConnection

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

Returns: true if the connection should be closed

See Also: shouldCloseConnection SC_OK

writeRequestLine

protected void writeRequestLine(HttpState state, HttpConnection conn)
Special Connect request.

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

Copyright (c) 1999-2005 - Apache Software Foundation