|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.commons.httpclient.HttpMethodBase
An abstract base implementation of HttpMethod.
At minimum, subclasses will need to override:
getName() to return the approriate name for this method
When a method's request may contain a body, subclasses will typically want to override:
getRequestContentLength() to indicate the length (in bytes)
of that bodywriteRequestBody(HttpState,HttpConnection)
to write the bodyWhen a method requires additional request headers, subclasses will typically want to override:
addRequestHeaders(HttpState,HttpConnection)
to write those headers
When a method expects specific response headers, subclasses may want to override:
processResponseHeaders(HttpState,HttpConnection)
to handle those headers
| Field Summary | |
protected static org.apache.commons.httpclient.Header |
USER_AGENT
The User-Agent header sent on every request. |
| Constructor Summary | |
HttpMethodBase()
No-arg constructor. |
|
HttpMethodBase(java.lang.String uri)
Constructor specifying a URI. |
|
| Method Summary | |
protected void |
addAuthorizationRequestHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Generates Authorization request header if needed, as long as no Authorization request header already exists. |
protected void |
addContentLengthRequestHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Generates Content-Length or Transfer-Encoding: Chunked request header, as long as no Content-Length request header already exists. |
protected void |
addCookieRequestHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Generates Cookie request headers for those cookies
that match the given host, port and path. |
protected void |
addHostRequestHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Generates Host request header, as long as no Host request header already exists. |
protected void |
addProxyAuthorizationRequestHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Generates Proxy-Authorization request header if needed, as long as no Proxy-Authorization request header already exists. |
protected void |
addProxyConnectionHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Generates Proxy-Connection: Keep-Alive request header when communicating via a proxy server. |
void |
addRequestHeader(org.apache.commons.httpclient.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(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Generates all the required request headers
to be submitted via the given connection. |
void |
addResponseFooter(org.apache.commons.httpclient.Header footer)
Use this method internally to add footers. |
protected void |
addUserAgentRequestHeader(org.apache.commons.httpclient.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(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Execute this HTTP method. |
protected void |
fakeResponse(org.apache.commons.httpclient.StatusLine statusline,
org.apache.commons.httpclient.HeaderGroup responseheaders,
java.io.InputStream responseStream)
This method is a dirty hack intended to work around current (2.0) design flaw that prevents the user from obtaining correct status code, headers and response body from the preceding HTTP CONNECT method. |
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. |
java.lang.String |
getAuthenticationRealm()
Returns authentication realm, if it has been used during authentication process. |
protected static java.lang.String |
getContentCharSet(org.apache.commons.httpclient.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 |
boolean |
getFollowRedirects()
Returns true if the HTTP method should automatically follow HTTP redirects (status code 302, etc.), false otherwise. |
org.apache.commons.httpclient.HostConfiguration |
getHostConfiguration()
Returns the host configuration. |
HttpRecorder |
getHttpRecorder()
|
org.apache.commons.httpclient.MethodRetryHandler |
getMethodRetryHandler()
Returns the retry handler for this HTTP method |
abstract java.lang.String |
getName()
Obtains the name of the HTTP method as used in the HTTP request line, for example "GET" or "POST". |
java.lang.String |
getPath()
Gets the path of this HTTP method. |
java.lang.String |
getProxyAuthenticationRealm()
Returns proxy authentication realm, if it has been used during authentication process. |
java.lang.String |
getQueryString()
Gets the query string of this HTTP method. |
int |
getRecoverableExceptionCount()
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. |
protected int |
getRequestContentLength()
Return the length (in bytes) of my request body, suitable for use in a Content-Length header. |
org.apache.commons.httpclient.Header |
getRequestHeader(java.lang.String headerName)
Returns the specified request header. |
protected org.apache.commons.httpclient.HeaderGroup |
getRequestHeaderGroup()
Gets the header group storing the request headers. |
org.apache.commons.httpclient.Header[] |
getRequestHeaders()
Returns an array of the requests headers that the HTTP method currently has |
byte[] |
getResponseBody()
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 |
getResponseCharSet()
Returns the character encoding of the response from the Content-Type header. |
protected int |
getResponseContentLength()
Return the length (in bytes) of the response body, as specified in a Content-Length header. |
org.apache.commons.httpclient.Header |
getResponseFooter(java.lang.String footerName)
Gets the response footer associated with the given name. |
org.apache.commons.httpclient.Header[] |
getResponseFooters()
Returns an array of the response footers that the HTTP method currently has in the order in which they were read. |
org.apache.commons.httpclient.Header |
getResponseHeader(java.lang.String headerName)
Gets the response header associated with the given name. |
protected org.apache.commons.httpclient.HeaderGroup |
getResponseHeaderGroup()
Gets the header group storing the response headers. |
org.apache.commons.httpclient.Header[] |
getResponseHeaders()
Returns an array of the response headers that the HTTP method currently has in the order in which they were read. |
protected java.io.InputStream |
getResponseStream()
Returns a stream from which the body of the current response may be read. |
protected org.apache.commons.httpclient.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. |
org.apache.commons.httpclient.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. |
org.apache.commons.httpclient.URI |
getURI()
Returns the URI of the HTTP method |
boolean |
hasBeenUsed()
Returns true if the HTTP method has been already executed,
but not recycled. |
protected boolean |
isConnectionCloseForced()
Tests if the connection should be force-closed when no longer needed. |
boolean |
isHttp11()
Returns true if version 1.1 of the HTTP protocol should be used per default, false if version 1.0 should be used. |
boolean |
isStrictMode()
Returns the value of the strict mode flag. |
protected void |
processResponseBody(org.apache.commons.httpclient.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(org.apache.commons.httpclient.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(org.apache.commons.httpclient.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(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Reads the response from the given connection. |
protected void |
readResponseBody(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Read the response body from the given HttpConnection. |
protected void |
readResponseHeaders(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Reads the response headers from the given connection. |
protected void |
readStatusLine(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Read the status line from the given HttpConnection, setting my
status code and status
text. |
void |
recycle()
Recycles the HTTP method so that it can be used again. |
void |
releaseConnection()
Releases the connection being used by this HTTP method. |
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(org.apache.commons.httpclient.HostConfiguration hostConfiguration)
Sets the host configuration. |
void |
setHttp11(boolean http11)
/** Sets whether version 1.1 of the HTTP protocol should be used per default. |
void |
setHttpRecorder(HttpRecorder httpRecorder)
|
void |
setMethodRetryHandler(org.apache.commons.httpclient.MethodRetryHandler handler)
Sets the retry handler for this HTTP method |
void |
setPath(java.lang.String path)
Sets the path of the HTTP method. |
void |
setQueryString(org.apache.commons.httpclient.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(org.apache.commons.httpclient.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)
Defines how strictly HttpClient follows the HTTP protocol specification (RFC 2616 and other relevant RFCs). |
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(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Sends the request via the given connection. |
protected boolean |
writeRequestBody(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Writes the request body to the given connection. |
protected void |
writeRequestHeaders(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
Writes the request headers to the given connection. |
protected void |
writeRequestLine(org.apache.commons.httpclient.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 static final org.apache.commons.httpclient.Header USER_AGENT
| 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 recognised| Method Detail |
public abstract java.lang.String getName()
getName in interface HttpMethod
public org.apache.commons.httpclient.URI getURI()
throws org.apache.commons.httpclient.URIException
getURI in interface HttpMethodURIException - If the URI cannot be created.HttpMethod.getURI()public void setFollowRedirects(boolean followRedirects)
setFollowRedirects in interface HttpMethodfollowRedirects - true if the method will automatically follow redirects,
false otherwise.public boolean getFollowRedirects()
getFollowRedirects in interface HttpMethodpublic void setHttp11(boolean http11)
http11 - true to use HTTP/1.1, false to use 1.0public boolean getDoAuthentication()
getDoAuthentication in interface HttpMethodHttpMethod.setDoAuthentication(boolean)public void setDoAuthentication(boolean doAuthentication)
setDoAuthentication in interface HttpMethoddoAuthentication - true to process authentication challenges
authomatically, false otherwise.HttpMethod.getDoAuthentication()public boolean isHttp11()
public void setPath(java.lang.String path)
setPath in interface HttpMethodpath - the path of the HTTP method. The path is expected
to be URL-encodedpublic void addRequestHeader(org.apache.commons.httpclient.Header header)
addRequestHeader in interface HttpMethodheader - the header to add to the requestHttpMethod.addRequestHeader(String,String),
HttpMethod.getRequestHeader(String),
HttpMethod.removeRequestHeader(String)public void addResponseFooter(org.apache.commons.httpclient.Header footer)
addResponseFooter in interface HttpMethodfooter - The footer to add.public java.lang.String getPath()
getPath in interface HttpMethodpublic void setQueryString(java.lang.String queryString)
setQueryString in interface HttpMethodqueryString - the query stringEncodingUtil.formUrlEncode(NameValuePair[], String)public void setQueryString(org.apache.commons.httpclient.NameValuePair[] params)
setQueryString in interface HttpMethodparams - an array of NameValuePairs 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 HttpMethodHttpMethod.setQueryString(NameValuePair[]),
HttpMethod.setQueryString(String)
public void setRequestHeader(java.lang.String headerName,
java.lang.String headerValue)
setRequestHeader in interface HttpMethodheaderName - the header's nameheaderValue - the header's valueHttpMethod.setRequestHeader(Header),
HttpMethod.getRequestHeader(String),
HttpMethod.removeRequestHeader(String)public void setRequestHeader(org.apache.commons.httpclient.Header header)
setRequestHeader in interface HttpMethodheader - the headerHttpMethod.setRequestHeader(String,String),
HttpMethod.getRequestHeader(String),
HttpMethod.removeRequestHeader(String)public org.apache.commons.httpclient.Header getRequestHeader(java.lang.String headerName)
getRequestHeader in interface HttpMethodheaderName - The name of the header to be returned.
public org.apache.commons.httpclient.Header[] getRequestHeaders()
getRequestHeaders in interface HttpMethodHttpMethod.addRequestHeader(Header),
HttpMethod.addRequestHeader(String,String)protected org.apache.commons.httpclient.HeaderGroup getRequestHeaderGroup()
header group storing the request headers.
protected org.apache.commons.httpclient.HeaderGroup getResponseTrailerHeaderGroup()
header group storing the response trailer headers
as per RFC 2616 section 3.6.1.
protected org.apache.commons.httpclient.HeaderGroup getResponseHeaderGroup()
header group storing the response headers.
public int getStatusCode()
getStatusCode in interface HttpMethodpublic org.apache.commons.httpclient.StatusLine getStatusLine()
getStatusLine in interface HttpMethodpublic org.apache.commons.httpclient.Header[] getResponseHeaders()
getResponseHeaders in interface HttpMethodpublic org.apache.commons.httpclient.Header getResponseHeader(java.lang.String headerName)
getResponseHeader in interface HttpMethodheaderName - the header name to match
protected int getResponseContentLength()
Return -1 when the content-length is unknown.
public byte[] getResponseBody()
getResponseBody in interface HttpMethod
public java.io.InputStream getResponseBodyAsStream()
throws java.io.IOException
InputStream.
If response body is not available, returns null
getResponseBodyAsStream in interface HttpMethodjava.io.IOException - If an I/O (transport) problem occurs while obtaining the
response body.public java.lang.String getResponseBodyAsString()
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.
getResponseBodyAsString in interface HttpMethodpublic org.apache.commons.httpclient.Header[] getResponseFooters()
getResponseFooters in interface HttpMethodpublic org.apache.commons.httpclient.Header getResponseFooter(java.lang.String footerName)
getResponseFooter in interface HttpMethodfooterName - 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 HttpMethodpublic void setStrictMode(boolean strictMode)
setStrictMode in interface HttpMethodstrictMode - true for strict mode, false otherwiseHttpMethod.isStrictMode()public boolean isStrictMode()
isStrictMode in interface HttpMethodHttpMethod.setStrictMode(boolean)
public void addRequestHeader(java.lang.String headerName,
java.lang.String headerValue)
addRequestHeader in interface HttpMethodheaderName - 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(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws org.apache.commons.httpclient.HttpException,
org.apache.commons.httpclient.HttpRecoverableException,
java.io.IOException
execute in interface HttpMethodstate - 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.
Note that we cannot currently support redirects that
change the HttpConnection parameters (host, port, protocol)
because we don't yet have a good way to get the new connection.
For the time being, we just return the 302 response, and allow
the user agent to resubmit if desired.
java.io.IOException - if an I/O (transport) error occurs
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP methodpublic boolean hasBeenUsed()
executed,
but not recycled.
hasBeenUsed in interface HttpMethodpublic void recycle()
recycle in interface HttpMethodreleaseConnection()public void releaseConnection()
releaseConnection in interface HttpMethodpublic void removeRequestHeader(java.lang.String headerName)
removeRequestHeader in interface HttpMethodheaderName - the header namepublic boolean validate()
validate in interface HttpMethodprotected int getRequestContentLength()
Return -1 when the content-length is unknown.
This implementation returns 0, indicating that the request has no body.
protected void addAuthorizationRequestHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP method
protected void addContentLengthRequestHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP method
protected void addCookieRequestHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.HttpException
cookies
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
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP method
protected void addHostRequestHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP method
protected void addProxyAuthorizationRequestHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP method
protected void addProxyConnectionHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP method
protected void addRequestHeaders(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.HttpException
headers
to be submitted via the given connection.
This implementation adds User-Agent, Host, Cookie, Content-Length, Transfer-Encoding, and Authorization 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 method
java.io.IOException - if an I/O (transport) error occurs
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP methodwriteRequestHeaders(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)
protected void addUserAgentRequestHeader(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP method
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
recycled
protected void checkUsed()
throws java.lang.IllegalStateException
IllegalStateException if the HTTP method has not been
executed since last recycle.
java.lang.IllegalStateException - if not used
protected 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(org.apache.commons.httpclient.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(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection),
readResponseBody(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)
protected void processResponseHeaders(org.apache.commons.httpclient.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(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection),
readResponseHeaders(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)
protected void processStatusLine(org.apache.commons.httpclient.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(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection),
readStatusLine(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)
protected void readResponse(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws org.apache.commons.httpclient.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
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP method
protected void readResponseBody(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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 method
java.io.IOException - if an I/O (transport) error occurs
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP methodreadResponse(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection),
processResponseBody(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)
protected void readResponseHeaders(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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 method
java.io.IOException - if an I/O (transport) error occurs
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP methodreadResponse(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection),
processResponseHeaders(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)
protected void readStatusLine(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.HttpRecoverableException,
org.apache.commons.httpclient.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 method
java.io.IOException - if an I/O (transport) error occurs
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP methodStatusLine
protected void writeRequest(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP method
protected boolean writeRequestBody(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP method
protected void writeRequestHeaders(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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 method
java.io.IOException - if an I/O (transport) error occurs
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP methodaddRequestHeaders(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection),
getRequestHeaders()
protected void writeRequestLine(org.apache.commons.httpclient.HttpState state,
HttpConnection conn)
throws java.io.IOException,
org.apache.commons.httpclient.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 method
java.io.IOException - if an I/O (transport) error occurs
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP methodgenerateRequestLine(org.apache.commons.httpclient.HttpConnection, java.lang.String, java.lang.String, java.lang.String, java.lang.String)public java.lang.String getProxyAuthenticationRealm()
public java.lang.String getAuthenticationRealm()
protected static java.lang.String getContentCharSet(org.apache.commons.httpclient.Header contentheader)
contentheader - The content header.
public java.lang.String getRequestCharSet()
public java.lang.String getResponseCharSet()
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.
public org.apache.commons.httpclient.HostConfiguration getHostConfiguration()
host configuration.
getHostConfiguration in interface HttpMethodpublic void setHostConfiguration(org.apache.commons.httpclient.HostConfiguration hostConfiguration)
host configuration.
hostConfiguration - The hostConfiguration to setpublic org.apache.commons.httpclient.MethodRetryHandler getMethodRetryHandler()
retry handler for this HTTP method
public void setMethodRetryHandler(org.apache.commons.httpclient.MethodRetryHandler handler)
retry handler for this HTTP method
handler - the methodRetryHandler to use when this method executed
protected void fakeResponse(org.apache.commons.httpclient.StatusLine statusline,
org.apache.commons.httpclient.HeaderGroup responseheaders,
java.io.InputStream responseStream)
public HttpRecorder getHttpRecorder()
getHttpRecorder in interface HttpMethodpublic void setHttpRecorder(HttpRecorder httpRecorder)
setHttpRecorder in interface HttpMethodhttpRecorder - HttpRecorder to set and record to.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||