com.microsoft.tfs.core.httpclient
Class ConnectMethod

java.lang.Object
  extended by com.microsoft.tfs.core.httpclient.HttpMethodBase
      extended by com.microsoft.tfs.core.httpclient.ConnectMethod
All Implemented Interfaces:
HttpMethod

public class ConnectMethod
extends HttpMethodBase

Establishes a tunneled HTTP connection via the CONNECT method.

Since:
2.0

Field Summary
static java.lang.String NAME
          the name of this method
 
Fields inherited from class com.microsoft.tfs.core.httpclient.HttpMethodBase
effectiveVersion, statusLine
 
Constructor Summary
ConnectMethod()
          Deprecated. 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
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.
 java.lang.String getName()
          Provide the name of this method.
 java.lang.String getPath()
          Gets the path of this HTTP method.
 URI getURI()
          Returns the URI of the HTTP 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 com.microsoft.tfs.core.httpclient.HttpMethodBase
abort, addHostRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, generateRequestLine, getContentCharSet, getDoAuthentication, getEffectiveVersion, getFollowRedirects, getHostAuthState, getHostConfiguration, getMethodRetryHandler, getParams, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
the name of this method

Constant Field Value:
"CONNECT"
See Also:
Constant Field Values
Constructor Detail

ConnectMethod

@Deprecated
public ConnectMethod()
Deprecated. use #ConnectMethod(HttpHost); Create a connect method.

Since:
3.0

ConnectMethod

@Deprecated
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

ConnectMethod

public ConnectMethod(HostConfiguration targethost)
Create a connect method.

Since:
3.0
Method Detail

getName

public java.lang.String getName()
Provide the name of this method.

Specified by:
getName in interface HttpMethod
Specified by:
getName in class HttpMethodBase
Returns:
the String "CONNECT"

getPath

public java.lang.String getPath()
Description copied from class: HttpMethodBase
Gets 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:
getPath in interface HttpMethod
Overrides:
getPath in class HttpMethodBase
Returns:
the path to request or "/" if the path is blank.

getURI

public URI getURI()
           throws URIException
Description copied from class: HttpMethodBase
Returns the URI of the HTTP method

Specified by:
getURI in interface HttpMethod
Overrides:
getURI in class HttpMethodBase
Returns:
The URI
See Also:
HttpMethod.getURI()
Throws:
URIException - If the URI cannot be created.

addCookieRequestHeader

protected void addCookieRequestHeader(HttpState state,
                                      HttpConnection conn)
                               throws java.io.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
See Also:
HttpMethodBase.addCookieRequestHeader(HttpState, HttpConnection)
Throws:
java.io.IOException - when errors occur reading or writing to/from the connection
HttpException - when a recoverable error occurs

addRequestHeaders

protected void addRequestHeaders(HttpState state,
                                 HttpConnection conn)
                          throws java.io.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
See Also:
HttpMethodBase.writeRequestHeaders(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
Throws:
java.io.IOException - when an error occurs writing the request
HttpException - when a HTTP protocol error occurs

execute

public int execute(HttpState state,
                   HttpConnection conn)
            throws java.io.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 class HttpMethodBase
Parameters:
state - the current http state
conn - the connection to write to
Returns:
the http status code from execution
See Also:
HttpConnection.tunnelCreated()
Throws:
HttpException - when an error occurs writing the headers
java.io.IOException - when an error occurs writing the headers

writeRequestLine

protected void writeRequestLine(HttpState state,
                                HttpConnection conn)
                         throws java.io.IOException,
                                HttpException
Special Connect request.

Overrides:
writeRequestLine in class HttpMethodBase
Parameters:
state - the current http state
conn - the connection to write to
See Also:
HttpMethodBase.generateRequestLine(com.microsoft.tfs.core.httpclient.HttpConnection, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
Throws:
java.io.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 in question
Returns:
true if the connection should be closed
See Also:
HttpMethodBase.shouldCloseConnection(HttpConnection), HttpStatus.SC_OK


© 2015 Microsoft. All rights reserved.