Class ConnectMethod
java.lang.Object
org.apache.commons.httpclient.HttpMethodBase
org.apache.commons.httpclient.ConnectMethod
- All Implemented Interfaces:
HttpMethod
Establishes a tunneled HTTP connection via the CONNECT method.
- Since:
- 2.0
- Version:
- $Revision: 483949 $ $Date: 2006-12-08 12:34:50 +0100 (Fri, 08 Dec 2006) $
- Author:
- Ortwin Gl???ck, dIon Gillard, Mike Bowler, Oleg Kalnichevski
-
Field Summary
FieldsFields inherited from class HttpMethodBase
effectiveVersion, statusLine -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.use #ConnectMethod(HttpHost); Create a connect method.ConnectMethod(HostConfiguration targethost) 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
Modifier and TypeMethodDescriptionprotected voidaddCookieRequestHeader(HttpState state, HttpConnection conn) This method does nothing.protected voidaddRequestHeaders(HttpState state, HttpConnection conn) Populates the request headers map to with additionalheadersto be submitted to the givenHttpConnection.intexecute(HttpState state, HttpConnection conn) Execute this method and create a tunneled HttpConnection.getName()Provide thenameof this method.getPath()Gets the path of this HTTP method.getURI()Returns the URI of the HTTP methodprotected booleanReturnstrueif the status code is anything other than SC_OK,falseotherwise.protected voidwriteRequestLine(HttpState state, HttpConnection conn) Special Connect request.Methods inherited from class HttpMethodBase
abort, addHostRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getEffectiveVersion, getFollowRedirects, getHostAuthState, getHostConfiguration, getMethodRetryHandler, getParams, getProxyAuthenticationRealm, getProxyAuthState, getQueryString, getRecoverableExceptionCount, getRequestCharSet, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getRequestHeaders, getResponseBody, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, hasBeenUsed, isAborted, isConnectionCloseForced, isHttp11, isRequestSent, isStrictMode, processCookieHeaders, 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, validate, writeRequest, writeRequestBody, writeRequestHeaders
-
Field Details
-
NAME
-
-
Constructor Details
-
ConnectMethod
public ConnectMethod()Deprecated.use #ConnectMethod(HttpHost); Create a connect method.- Since:
- 3.0
-
ConnectMethod
Deprecated.the wrapped method is no longer used Create a connect method wrapping the existing method- Parameters:
method- themethodto execute after connecting to the server
-
ConnectMethod
-
-
Method Details
-
getName
Provide thenameof this method.- Specified by:
getNamein interfaceHttpMethod- Specified by:
getNamein classHttpMethodBase- Returns:
- the String "CONNECT"
-
getPath
Description copied from class:HttpMethodBaseGets the path of this HTTP method. Calling this method after the request has been executed will return the actual path, following any redirects automatically handled by this HTTP method.- Specified by:
getPathin interfaceHttpMethod- Overrides:
getPathin classHttpMethodBase- Returns:
- the path to request or "/" if the path is blank.
-
getURI
Description copied from class:HttpMethodBaseReturns the URI of the HTTP method- Specified by:
getURIin interfaceHttpMethod- Overrides:
getURIin classHttpMethodBase- Returns:
- The URI
- Throws:
URIException- If the URI cannot be created.- See Also:
-
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:
addCookieRequestHeaderin classHttpMethodBase- Parameters:
state- current state of http requestsconn- the connection to use for I/O- Throws:
IOException- when errors occur reading or writing to/from the connectionHttpException- when a recoverable error occurs- See Also:
-
addRequestHeaders
protected void addRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException Populates the request headers map to with additionalheadersto be submitted to the givenHttpConnection.This implementation adds User-Agent, Host, and Proxy-Authorization headers, when appropriate.
- Overrides:
addRequestHeadersin classHttpMethodBase- Parameters:
state- the client stateconn- theHttpConnectionthe headers will eventually be written to- Throws:
IOException- when an error occurs writing the requestHttpException- when a HTTP protocol error occurs- See Also:
-
execute
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:
executein interfaceHttpMethod- Overrides:
executein classHttpMethodBase- Parameters:
state- the current http stateconn- the connection to write to- Returns:
- the http status code from execution
- Throws:
HttpException- when an error occurs writing the headersIOException- when an error occurs writing the headers- See Also:
-
writeRequestLine
protected void writeRequestLine(HttpState state, HttpConnection conn) throws IOException, HttpException Special Connect request.- Overrides:
writeRequestLinein classHttpMethodBase- Parameters:
state- the current http stateconn- the connection to write to- Throws:
IOException- when an error occurs writing the requestHttpException- when an error occurs writing the request- See Also:
-
shouldCloseConnection
Returnstrueif the status code is anything other than SC_OK,falseotherwise.- Overrides:
shouldCloseConnectionin classHttpMethodBase- Parameters:
conn- the connection in question- Returns:
trueif the connection should be closed- See Also:
-