|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microsoft.tfs.core.httpclient.HttpMethodBase
public abstract class HttpMethodBase
An abstract base implementation of HttpMethod.
At minimum, subclasses will need to override:
getName()
to return the approriate name for this methodWhen a method requires additional request headers, subclasses will typically want to override:
addRequestHeaders(HttpState,HttpConnection)
to
write those headersWhen a method expects specific response headers, subclasses may want to override:
processResponseHeaders(HttpState,HttpConnection)
to handle those headers
Field Summary | |
---|---|
protected HttpVersion |
effectiveVersion
HTTP protocol version used for execution of this method. |
protected StatusLine |
statusLine
The Status-Line from the response. |
Constructor Summary | |
---|---|
HttpMethodBase()
No-arg constructor. |
|
HttpMethodBase(java.lang.String uri)
Constructor specifying a URI. |
Method Summary | |
---|---|
void |
abort()
Aborts the execution of this method. |
protected void |
addCookieRequestHeader(HttpState state,
HttpConnection conn)
Generates Cookie request headers for those cookie
s that match the given host, port and path. |
protected void |
addHostRequestHeader(HttpState state,
HttpConnection conn)
Generates Host request header, as long as no Host request header already exists. |
protected void |
addProxyConnectionHeader(HttpState state,
HttpConnection conn)
Generates Proxy-Connection: Keep-Alive request header when communicating via a proxy server. |
void |
addRequestHeader(Header header)
Adds the specified request header, NOT overwriting any previous value. |
void |
addRequestHeader(java.lang.String headerName,
java.lang.String headerValue)
Adds the specified request header, NOT overwriting any previous value. |
protected void |
addRequestHeaders(HttpState state,
HttpConnection conn)
Generates all the required request header s to be submitted
via the given connection . |
void |
addResponseFooter(Header footer)
Use this method internally to add footers. |
protected void |
addUserAgentRequestHeader(HttpState state,
HttpConnection conn)
Generates default User-Agent request header, as long as no User-Agent request header already exists. |
protected void |
checkNotUsed()
Throws an IllegalStateException if the HTTP method has been
already executed , but not recycled . |
protected void |
checkUsed()
Throws an IllegalStateException if the HTTP method has not been
executed since last recycle . |
int |
execute(HttpState state,
HttpConnection conn)
Executes this method using the specified HttpConnection and
HttpState . |
protected static java.lang.String |
generateRequestLine(HttpConnection connection,
java.lang.String name,
java.lang.String requestPath,
java.lang.String query,
java.lang.String version)
Generates HTTP request line according to the specified attributes. |
protected java.lang.String |
getContentCharSet(Header contentheader)
Returns the character set from the Content-Type header. |
boolean |
getDoAuthentication()
Returns true if the HTTP method should automatically handle HTTP authentication challenges (status code 401, etc.), false otherwise |
HttpVersion |
getEffectiveVersion()
Returns the HTTP version used with this method (may be null if undefined, that is, the method has not been executed) |
boolean |
getFollowRedirects()
Returns true if the HTTP method should automatically follow HTTP redirects (status code 302, etc.), false otherwise. |
AuthState |
getHostAuthState()
Returns the target host authentication state |
HostConfiguration |
getHostConfiguration()
Deprecated. no longer applicable |
MethodRetryHandler |
getMethodRetryHandler()
Deprecated. use HttpMethodParams |
abstract java.lang.String |
getName()
Obtains the name of the HTTP method as used in the HTTP request line, for example "GET" or "POST". |
HttpMethodParams |
getParams()
Returns HTTP protocol parameters associated with
this method. |
java.lang.String |
getPath()
Gets the path of this HTTP method. |
AuthState |
getProxyAuthState()
Returns the proxy authentication state |
java.lang.String |
getQueryString()
Gets the query string of this HTTP method. |
int |
getRecoverableExceptionCount()
Deprecated. no longer used Returns the number of "recoverable" exceptions thrown and handled, to allow for monitoring the quality of the connection. |
java.lang.String |
getRequestCharSet()
Returns the character encoding of the request from the Content-Type header. |
Header |
getRequestHeader(java.lang.String headerName)
Returns the specified request header. |
protected HeaderGroup |
getRequestHeaderGroup()
Gets the header group storing the request headers. |
Header[] |
getRequestHeaders()
Returns an array of the requests headers that the HTTP method currently has |
Header[] |
getRequestHeaders(java.lang.String headerName)
Returns the request headers with the given name. |
byte[] |
getResponseBody()
Returns the response body of the HTTP method, if any, as an array of bytes. |
byte[] |
getResponseBody(int maxlen)
Returns the response body of the HTTP method, if any, as an array of bytes. |
java.io.InputStream |
getResponseBodyAsStream()
Returns the response body of the HTTP method, if any, as an InputStream . |
java.lang.String |
getResponseBodyAsString()
Returns the response body of the HTTP method, if any, as a String
. |
java.lang.String |
getResponseBodyAsString(int maxlen)
Returns the response body of the HTTP method, if any, as a String
. |
java.lang.String |
getResponseCharSet()
Returns the character encoding of the response from the Content-Type header. |
long |
getResponseContentLength()
Return the length (in bytes) of the response body, as specified in a Content-Length header. |
Header |
getResponseFooter(java.lang.String footerName)
Gets the response footer associated with the given name. |
Header[] |
getResponseFooters()
Returns an array of the response footers that the HTTP method currently has in the order in which they were read. |
Header |
getResponseHeader(java.lang.String headerName)
Gets the response header associated with the given name. |
protected HeaderGroup |
getResponseHeaderGroup()
Gets the header group storing the response headers. |
Header[] |
getResponseHeaders()
Returns an array of the response headers that the HTTP method currently has in the order in which they were read. |
Header[] |
getResponseHeaders(java.lang.String headerName)
Returns the response headers with the given name. |
protected java.io.InputStream |
getResponseStream()
Returns a stream from which the body of the current response may be read. |
protected HeaderGroup |
getResponseTrailerHeaderGroup()
Gets the header group storing the response trailer
headers as per RFC 2616 section 3.6.1. |
int |
getStatusCode()
Returns the response status code. |
StatusLine |
getStatusLine()
Provides access to the response status line. |
java.lang.String |
getStatusText()
Returns the status text (or "reason phrase") associated with the latest response. |
URI |
getURI()
Returns the URI of the HTTP method |
boolean |
hasBeenUsed()
Returns true if the HTTP method has been already executed , but not recycled . |
boolean |
isAborted()
Tests whether the execution of this method has been aborted |
protected boolean |
isConnectionCloseForced()
Tests if the connection should be force-closed when no longer needed. |
boolean |
isHttp11()
Deprecated. Use HttpMethodParams.getVersion() |
boolean |
isRequestSent()
Returns true if the HTTP has been transmitted to the target server in its entirety, false otherwise. |
boolean |
isStrictMode()
Deprecated. Use HttpParams.setParameter(String, Object)
to exercise a more granular control over HTTP protocol
strictness. |
protected void |
processCookieHeaders(CookieSpec parser,
Header[] headers,
HttpState state,
HttpConnection conn)
This method processes the specified cookie headers. |
protected void |
processResponseBody(HttpState state,
HttpConnection conn)
This method is invoked immediately after readResponseBody(HttpState,HttpConnection) and can be overridden
by sub-classes in order to provide custom body processing. |
protected void |
processResponseHeaders(HttpState state,
HttpConnection conn)
This method is invoked immediately after readResponseHeaders(HttpState,HttpConnection) and can be
overridden by sub-classes in order to provide custom response headers
processing. |
protected void |
processStatusLine(HttpState state,
HttpConnection conn)
This method is invoked immediately after readStatusLine(HttpState,HttpConnection) and can be overridden
by sub-classes in order to provide custom response status line
processing. |
protected void |
readResponse(HttpState state,
HttpConnection conn)
Reads the response from the given connection . |
protected void |
readResponseBody(HttpState state,
HttpConnection conn)
Read the response body from the given HttpConnection . |
protected void |
readResponseHeaders(HttpState state,
HttpConnection conn)
Reads the response headers from the given connection . |
protected void |
readStatusLine(HttpState state,
HttpConnection conn)
Read the status line from the given HttpConnection , setting my
status code and status text
. |
void |
recycle()
Deprecated. no longer supported and will be removed in the future version of HttpClient |
void |
releaseConnection()
Releases the connection being used by this HTTP method. |
void |
removeRequestHeader(Header header)
Removes the given request header. |
void |
removeRequestHeader(java.lang.String headerName)
Remove the request header associated with the given name. |
protected void |
responseBodyConsumed()
A response has been consumed. |
protected void |
setConnectionCloseForced(boolean b)
Sets whether or not the connection should be force-closed when no longer needed. |
void |
setDoAuthentication(boolean doAuthentication)
Sets whether or not the HTTP method should automatically handle HTTP authentication challenges (status code 401, etc.) |
void |
setFollowRedirects(boolean followRedirects)
Sets whether or not the HTTP method should automatically follow HTTP redirects (status code 302, etc.) |
void |
setHostConfiguration(HostConfiguration hostconfig)
Deprecated. no longer applicable |
void |
setHttp11(boolean http11)
Deprecated. Use HttpMethodParams.setVersion(HttpVersion) |
void |
setMethodRetryHandler(MethodRetryHandler handler)
Deprecated. use HttpMethodParams |
void |
setParams(HttpMethodParams params)
Assigns HTTP protocol parameters for this
method. |
void |
setPath(java.lang.String path)
Sets the path of the HTTP method. |
void |
setQueryString(NameValuePair[] params)
Sets the query string of this HTTP method. |
void |
setQueryString(java.lang.String queryString)
Sets the query string of this HTTP method. |
void |
setRequestHeader(Header header)
Sets the specified request header, overwriting any previous value. |
void |
setRequestHeader(java.lang.String headerName,
java.lang.String headerValue)
Set the specified request header, overwriting any previous value. |
protected void |
setResponseStream(java.io.InputStream responseStream)
Sets the response stream. |
void |
setStrictMode(boolean strictMode)
Deprecated. Use HttpParams.setParameter(String, Object)
to exercise a more granular control over HTTP protocol
strictness. |
void |
setURI(URI uri)
Sets the URI for this method. |
protected boolean |
shouldCloseConnection(HttpConnection conn)
Tests if the connection should be closed after the method has been executed. |
boolean |
validate()
Returns true the method is ready to execute, false otherwise. |
protected void |
writeRequest(HttpState state,
HttpConnection conn)
Sends the request via the given connection . |
protected boolean |
writeRequestBody(HttpState state,
HttpConnection conn)
Writes the request body to the given connection . |
protected void |
writeRequestHeaders(HttpState state,
HttpConnection conn)
Writes the request headers to the given connection
. |
protected void |
writeRequestLine(HttpState state,
HttpConnection conn)
Writes the request line to the given connection . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected StatusLine statusLine
protected HttpVersion effectiveVersion
Constructor Detail |
---|
public HttpMethodBase()
public HttpMethodBase(java.lang.String uri) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
uri
- either an absolute or relative URI. The URI is expected to be
URL-encoded
java.lang.IllegalArgumentException
- when URI is invalid
java.lang.IllegalStateException
- when protocol of the absolute URI is not recognisedMethod Detail |
---|
public abstract java.lang.String getName()
getName
in interface HttpMethod
public URI getURI() throws URIException
getURI
in interface HttpMethod
HttpMethod.getURI()
URIException
- If the URI cannot be created.public void setURI(URI uri) throws URIException
setURI
in interface HttpMethod
uri
- URI to be set
URIException
- if a URI cannot be setpublic void setFollowRedirects(boolean followRedirects)
setFollowRedirects
in interface HttpMethod
followRedirects
- true if the method will automatically follow redirects,
false otherwise.public boolean getFollowRedirects()
getFollowRedirects
in interface HttpMethod
@Deprecated public void setHttp11(boolean http11)
HttpMethodParams.setVersion(HttpVersion)
http11
- true to use HTTP/1.1, false to use 1.0public boolean getDoAuthentication()
getDoAuthentication
in interface HttpMethod
HttpMethod.setDoAuthentication(boolean)
public void setDoAuthentication(boolean doAuthentication)
setDoAuthentication
in interface HttpMethod
doAuthentication
- true to process authentication challenges authomatically,
false otherwise.HttpMethod.getDoAuthentication()
@Deprecated public boolean isHttp11()
HttpMethodParams.getVersion()
public void setPath(java.lang.String path)
setPath
in interface HttpMethod
path
- the path of the HTTP method. The path is expected to be
URL-encodedpublic void addRequestHeader(Header header)
addRequestHeader
in interface HttpMethod
header
- the header to add to the requestHttpMethod.addRequestHeader(String,String)
,
HttpMethod.getRequestHeader(String)
,
HttpMethod.removeRequestHeader(String)
public void addResponseFooter(Header footer)
addResponseFooter
in interface HttpMethod
footer
- The footer to add.public java.lang.String getPath()
getPath
in interface HttpMethod
public void setQueryString(java.lang.String queryString)
setQueryString
in interface HttpMethod
queryString
- the query stringEncodingUtil.formUrlEncode(NameValuePair[], String)
public void setQueryString(NameValuePair[] params)
setQueryString
in interface HttpMethod
params
- an array of NameValuePair
s to add as query string
parameters. The name/value pairs will be automcatically URL
encodedEncodingUtil.formUrlEncode(NameValuePair[], String)
,
setQueryString(String)
public java.lang.String getQueryString()
getQueryString
in interface HttpMethod
HttpMethod.setQueryString(NameValuePair[])
,
HttpMethod.setQueryString(String)
public void setRequestHeader(java.lang.String headerName, java.lang.String headerValue)
setRequestHeader
in interface HttpMethod
headerName
- the header's nameheaderValue
- the header's valueHttpMethod.setRequestHeader(Header)
,
HttpMethod.getRequestHeader(String)
,
HttpMethod.removeRequestHeader(String)
public void setRequestHeader(Header header)
setRequestHeader
in interface HttpMethod
header
- the headerHttpMethod.setRequestHeader(String,String)
,
HttpMethod.getRequestHeader(String)
,
HttpMethod.removeRequestHeader(String)
public Header getRequestHeader(java.lang.String headerName)
getRequestHeader
in interface HttpMethod
headerName
- The name of the header to be returned.
public Header[] getRequestHeaders()
getRequestHeaders
in interface HttpMethod
HttpMethod.addRequestHeader(Header)
,
HttpMethod.addRequestHeader(String,String)
public Header[] getRequestHeaders(java.lang.String headerName)
HttpMethod
getRequestHeaders
in interface HttpMethod
headerName
- the name of the headers to be returned.
HttpMethod.getRequestHeaders(java.lang.String)
protected HeaderGroup getRequestHeaderGroup()
header group
storing the request headers.
protected HeaderGroup getResponseTrailerHeaderGroup()
header group
storing the response trailer
headers as per RFC 2616 section 3.6.1.
protected HeaderGroup getResponseHeaderGroup()
header group
storing the response headers.
public Header[] getResponseHeaders(java.lang.String headerName)
HttpMethod
getResponseHeaders
in interface HttpMethod
headerName
- the name of the headers to be returned.
HttpMethod.getResponseHeaders(java.lang.String)
public int getStatusCode()
getStatusCode
in interface HttpMethod
public StatusLine getStatusLine()
getStatusLine
in interface HttpMethod
public Header[] getResponseHeaders()
getResponseHeaders
in interface HttpMethod
public Header getResponseHeader(java.lang.String headerName)
getResponseHeader
in interface HttpMethod
headerName
- the header name to match
public long getResponseContentLength()
Return -1 when the content-length is unknown.
public byte[] getResponseBody() throws java.io.IOException
getResponseBody
in interface HttpMethod
java.io.IOException
- If an I/O (transport) problem occurs while obtaining the response
body.public byte[] getResponseBody(int maxlen) throws java.io.IOException
If the response is large this method involves lots of array copying and
many object allocations, which makes it unsuitable for high-performance /
low-footprint applications. Those applications should use
getResponseBodyAsStream()
.
maxlen
- the maximum content length to accept (number of bytes).
java.io.IOException
- If an I/O (transport) problem occurs while obtaining the response
body.public java.io.InputStream getResponseBodyAsStream() throws java.io.IOException
InputStream
. If response body is not available, returns
null. If the response has been buffered this method returns a
new stream object on every call. If the response has not been buffered
the returned stream can only be read once.
getResponseBodyAsStream
in interface HttpMethod
null
.
java.io.IOException
- If an I/O (transport) problem occurs while obtaining the response
body.public java.lang.String getResponseBodyAsString() throws java.io.IOException
String
. If response body is not available or cannot be read, returns
null The string conversion on the data is done using the
character encoding specified in Content-Type header. Buffers the
response and this method can be called several times yielding the same
result each time.
Note: This will cause the entire response body to be buffered in memory.
A malicious server may easily exhaust all the VM memory. It is strongly
recommended, to use getResponseAsStream if the content length of the
response is unknown or resonably large.
getResponseBodyAsString
in interface HttpMethod
null
.
java.io.IOException
- If an I/O (transport) problem occurs while obtaining the response
body.public java.lang.String getResponseBodyAsString(int maxlen) throws java.io.IOException
String
. If response body is not available or cannot be read, returns
null The string conversion on the data is done using the
character encoding specified in Content-Type header. Buffers the
response and this method can be called several times yielding the same
result each time.
Note: This will cause the entire response body to be buffered in memory.
This method is safe if the content length of the response is unknown,
because the amount of memory used is limited.
If the response is large this method involves lots of array copying and
many object allocations, which makes it unsuitable for high-performance /
low-footprint applications. Those applications should use
getResponseBodyAsStream()
.
maxlen
- the maximum content length to accept (number of bytes). Note that,
depending on the encoding, this is not equal to the number of
characters.
null
.
java.io.IOException
- If an I/O (transport) problem occurs while obtaining the response
body.public Header[] getResponseFooters()
getResponseFooters
in interface HttpMethod
public Header getResponseFooter(java.lang.String footerName)
getResponseFooter
in interface HttpMethod
footerName
- the footer name to match
protected void setResponseStream(java.io.InputStream responseStream)
responseStream
- The new response stream.protected java.io.InputStream getResponseStream()
responseBodyConsumed
has been called, or if the stream
returned by a previous call has been closed, null
will be
returned.
public java.lang.String getStatusText()
getStatusText
in interface HttpMethod
@Deprecated public void setStrictMode(boolean strictMode)
HttpParams.setParameter(String, Object)
to exercise a more granular control over HTTP protocol
strictness.
setStrictMode
in interface HttpMethod
strictMode
- true for strict mode, false otherwiseHttpMethod.isStrictMode()
@Deprecated public boolean isStrictMode()
HttpParams.setParameter(String, Object)
to exercise a more granular control over HTTP protocol
strictness.
HttpMethod
isStrictMode
in interface HttpMethod
HttpMethod.setStrictMode(boolean)
public void addRequestHeader(java.lang.String headerName, java.lang.String headerValue)
addRequestHeader
in interface HttpMethod
headerName
- the header's nameheaderValue
- the header's valueHttpMethod.addRequestHeader(Header)
,
HttpMethod.getRequestHeader(String)
,
HttpMethod.removeRequestHeader(String)
protected boolean isConnectionCloseForced()
true
if the connection must be closedprotected void setConnectionCloseForced(boolean b)
true
in abnormal
circumstances, such as HTTP protocol violations.
b
- true
if the connection must be closed,
false
otherwise.protected boolean shouldCloseConnection(HttpConnection conn)
conn
- the connection in question
public int execute(HttpState state, HttpConnection conn) throws HttpException, java.io.IOException
HttpConnection
and
HttpState
.
execute
in interface HttpMethod
state
- state
information to associate with this
request. Must be non-null.conn
- the connection
to used to execute this HTTP
method. Must be non-null.
java.io.IOException
- if an I/O (transport) error occurs
HttpException
- if a protocol exception occurs.public void abort()
abort
in interface HttpMethod
HttpMethod.execute(HttpState, HttpConnection)
public boolean hasBeenUsed()
executed
, but not recycled
.
hasBeenUsed
in interface HttpMethod
@Deprecated public void recycle()
recycle
in interface HttpMethod
releaseConnection()
public void releaseConnection()
releaseConnection
in interface HttpMethod
public void removeRequestHeader(java.lang.String headerName)
removeRequestHeader
in interface HttpMethod
headerName
- the header namepublic void removeRequestHeader(Header header)
removeRequestHeader
in interface HttpMethod
header
- the headerpublic boolean validate()
validate
in interface HttpMethod
protected void addCookieRequestHeader(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
cookie
s that match the given host, port and path.
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
method
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void addHostRequestHeader(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
method
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void addProxyConnectionHeader(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
method
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void addRequestHeaders(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
header
s to be submitted
via the given connection
.
This implementation adds User-Agent, Host, Cookie, Authorization, Proxy-Authorization and Proxy-Connection headers, when appropriate.
Subclasses may want to override this method to to add additional headers, and may choose to invoke this implementation (via super) to add the "standard" headers.
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
methodwriteRequestHeaders(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void addUserAgentRequestHeader(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
method
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void checkNotUsed() throws java.lang.IllegalStateException
IllegalStateException
if the HTTP method has been
already executed
, but not recycled
.
java.lang.IllegalStateException
- if the method has been used and not recycledprotected void checkUsed() throws java.lang.IllegalStateException
IllegalStateException
if the HTTP method has not been
executed
since last recycle
.
java.lang.IllegalStateException
- if not usedprotected static java.lang.String generateRequestLine(HttpConnection connection, java.lang.String name, java.lang.String requestPath, java.lang.String query, java.lang.String version)
connection
- the connection
used to execute this HTTP
methodname
- the method name generate a request forrequestPath
- the path string for the requestquery
- the query string for the requestversion
- the protocol version to use (e.g. HTTP/1.0)
protected void processResponseBody(HttpState state, HttpConnection conn)
readResponseBody(HttpState,HttpConnection)
and can be overridden
by sub-classes in order to provide custom body processing.
This implementation does nothing.
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
methodreadResponse(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
,
readResponseBody(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
protected void processResponseHeaders(HttpState state, HttpConnection conn)
readResponseHeaders(HttpState,HttpConnection)
and can be
overridden by sub-classes in order to provide custom response headers
processing.
This implementation will handle the Set-Cookie and
Set-Cookie2 headers, if any, adding the relevant cookies to the
given HttpState
.
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
methodreadResponse(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
,
readResponseHeaders(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
protected void processCookieHeaders(CookieSpec parser, Header[] headers, HttpState state, HttpConnection conn)
processResponseHeaders(HttpState,HttpConnection)
headers
- cookie Header
s to be processedstate
- the state
information associated with this HTTP
methodconn
- the connection
used to execute this HTTP
methodprotected void processStatusLine(HttpState state, HttpConnection conn)
readStatusLine(HttpState,HttpConnection)
and can be overridden
by sub-classes in order to provide custom response status line
processing.
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
methodreadResponse(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
,
readStatusLine(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
protected void readResponse(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
connection
.
The response is processed as the following sequence of actions:
readStatusLine(HttpState,HttpConnection)
is invoked to read the
request line.processStatusLine(HttpState,HttpConnection)
is invoked, allowing
the method to process the status line if desired.readResponseHeaders(HttpState,HttpConnection)
is invoked to read
the associated headers.processResponseHeaders(HttpState,HttpConnection)
is invoked,
allowing the method to process the headers if desired.readResponseBody(HttpState,HttpConnection)
is invoked to read
the associated body (if any).processResponseBody(HttpState,HttpConnection)
is invoked,
allowing the method to process the response body if desired.
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
method
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void readResponseBody(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
HttpConnection
.
The current implementation wraps the socket level stream with an appropriate stream for the type of response (chunked, content-length, or auto-close). If there is no response body, the connection associated with the request will be returned to the connection manager.
Subclasses may want to override this method to to customize the processing.
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
methodreadResponse(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
,
processResponseBody(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void readResponseHeaders(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
connection
.
Subclasses may want to override this method to to customize the processing.
"It must be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma." - HTTP/1.0 (4.3)
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
methodreadResponse(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
,
processResponseHeaders(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void readStatusLine(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
HttpConnection
, setting my
status code
and status text
.
Subclasses may want to override this method to to customize the processing.
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
methodStatusLine
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void writeRequest(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
Sends the request via the given connection
.
The request is written as the following sequence of actions:
writeRequestLine(HttpState, HttpConnection)
is invoked to write
the request line.writeRequestHeaders(HttpState, HttpConnection)
is invoked to
write the associated headers.writeRequestBody(HttpState, HttpConnection)
is invoked to write
the body part of the request.Subclasses may want to override one or more of the above methods to to customize the processing. (Or they may choose to override this method if dramatically different processing is required.)
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
method
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
connection
.
This method should return true if the request body was actually sent (or is empty), or false if it could not be sent for some reason.
This implementation writes nothing and returns true.
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
method
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void writeRequestHeaders(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
connection
.
This implementation invokes
addRequestHeaders(HttpState,HttpConnection)
, and then writes
each header to the request stream.
Subclasses may want to override this method to to customize the processing.
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
methodaddRequestHeaders(com.microsoft.tfs.core.httpclient.HttpState, com.microsoft.tfs.core.httpclient.HttpConnection)
,
getRequestHeaders()
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void writeRequestLine(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
connection
.
Subclasses may want to override this method to to customize the processing.
state
- the state
information associated with this
methodconn
- the connection
used to execute this HTTP
methodgenerateRequestLine(com.microsoft.tfs.core.httpclient.HttpConnection, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions can
be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.public HttpMethodParams getParams()
HTTP protocol parameters
associated with
this method.
getParams
in interface HttpMethod
HttpMethodParams
public void setParams(HttpMethodParams params)
HTTP protocol parameters
for this
method.
setParams
in interface HttpMethod
HttpMethodParams
public HttpVersion getEffectiveVersion()
protected java.lang.String getContentCharSet(Header contentheader)
contentheader
- The content header.
public java.lang.String getRequestCharSet()
public java.lang.String getResponseCharSet()
@Deprecated public int getRecoverableExceptionCount()
protected void responseBodyConsumed()
The default behavior for this class is to check to see if the connection should be closed, and close if need be, and to ensure that the connection is returned to the connection manager - if and only if we are not still inside the execute call.
@Deprecated public HostConfiguration getHostConfiguration()
host configuration
.
getHostConfiguration
in interface HttpMethod
@Deprecated public void setHostConfiguration(HostConfiguration hostconfig)
host configuration
.
hostconfig
- The hostConfiguration to set@Deprecated public MethodRetryHandler getMethodRetryHandler()
HttpMethodParams
retry handler
for this HTTP method
@Deprecated public void setMethodRetryHandler(MethodRetryHandler handler)
HttpMethodParams
retry handler
for this HTTP method
handler
- the methodRetryHandler to use when this method executedpublic AuthState getHostAuthState()
authentication state
getHostAuthState
in interface HttpMethod
public AuthState getProxyAuthState()
authentication state
getProxyAuthState
in interface HttpMethod
public boolean isAborted()
public boolean isRequestSent()
isRequestSent
in interface HttpMethod
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |