|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
HttpMethod interface represents a request to be sent via a
HTTP connection
and a corresponding response.
Method Summary | |
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. |
void |
addResponseFooter(org.apache.commons.httpclient.Header footer)
Add a footer to this method's response. |
int |
execute(org.apache.commons.httpclient.HttpState state,
HttpConnection connection)
Executes this method using the specified HttpConnection and
HttpState . |
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()
Gets the host configuration for this method. |
HttpRecorder |
getHttpRecorder()
|
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()
Returns the path of the HTTP method. |
java.lang.String |
getQueryString()
Returns the query string of this HTTP method. |
org.apache.commons.httpclient.Header |
getRequestHeader(java.lang.String headerName)
Gets the request header with the given name. |
org.apache.commons.httpclient.Header[] |
getRequestHeaders()
Returns the current request headers for this HTTP method. |
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 . |
org.apache.commons.httpclient.Header |
getResponseFooter(java.lang.String footerName)
Return the specified response footer. |
org.apache.commons.httpclient.Header[] |
getResponseFooters()
Returns the response footers from the most recent execution of this request. |
org.apache.commons.httpclient.Header |
getResponseHeader(java.lang.String headerName)
Returns the specified response header. |
org.apache.commons.httpclient.Header[] |
getResponseHeaders()
Returns the response headers from the most recent execution of this request. |
int |
getStatusCode()
Returns the status code associated with the latest response. |
org.apache.commons.httpclient.StatusLine |
getStatusLine()
Returns the Status-Line from the most recent response for this method, or null if the method has not been executed. |
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 for this method. |
boolean |
hasBeenUsed()
Returns true if the HTTP method has been already executed ,
but not recycled . |
boolean |
isStrictMode()
Returns the value of the strict mode flag. |
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)
Removes all request headers with the given name. |
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 |
setHttpRecorder(HttpRecorder httpRecorder)
|
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 the 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)
Sets the specified request header, overwriting any previous value. |
void |
setStrictMode(boolean strictMode)
Defines how strictly the method follows the HTTP protocol specification. |
boolean |
validate()
Returns true the method is ready to execute, false otherwise. |
Method Detail |
public java.lang.String getName()
public org.apache.commons.httpclient.HostConfiguration getHostConfiguration()
null
if none is setpublic void setPath(java.lang.String path)
path
- The path of the HTTP method. The path is expected
to be URL encoded.public java.lang.String getPath()
public org.apache.commons.httpclient.URI getURI() throws org.apache.commons.httpclient.URIException
URIException
- if a URI cannot be constructedpublic void setStrictMode(boolean strictMode)
strictMode
- true for strict mode, false otherwiseisStrictMode()
public boolean isStrictMode()
setStrictMode(boolean)
public void setRequestHeader(java.lang.String headerName, java.lang.String headerValue)
headerName
- the header's nameheaderValue
- the header's valuesetRequestHeader(Header)
,
getRequestHeader(String)
,
removeRequestHeader(String)
public void setRequestHeader(org.apache.commons.httpclient.Header header)
header
- the header to be setsetRequestHeader(String,String)
,
getRequestHeader(String)
,
removeRequestHeader(String)
public void addRequestHeader(java.lang.String headerName, java.lang.String headerValue)
headerName
- the header's nameheaderValue
- the header's valueaddRequestHeader(Header)
,
getRequestHeader(String)
,
removeRequestHeader(String)
public void addRequestHeader(org.apache.commons.httpclient.Header header)
header
- the headeraddRequestHeader(String,String)
,
getRequestHeader(String)
,
removeRequestHeader(String)
public org.apache.commons.httpclient.Header getRequestHeader(java.lang.String headerName)
headerName
- the header name
public void removeRequestHeader(java.lang.String headerName)
headerName
- the header namepublic boolean getFollowRedirects()
public void setFollowRedirects(boolean followRedirects)
followRedirects
- true if the method will automatically follow redirects,
false otherwisepublic void setQueryString(java.lang.String queryString)
queryString
- the query to be used in the request, with no leading '?' charactergetQueryString()
,
setQueryString(NameValuePair[])
public void setQueryString(org.apache.commons.httpclient.NameValuePair[] params)
params
- An array of NameValuePair
s to use as the query string.
The name/value pairs will be automatically URL encoded and should not
have been encoded previously.getQueryString()
,
setQueryString(String)
,
EncodingUtil.formUrlEncode(NameValuePair[], String)
public java.lang.String getQueryString()
setQueryString(NameValuePair[])
,
setQueryString(String)
public org.apache.commons.httpclient.Header[] getRequestHeaders()
addRequestHeader
.
If there are multiple request headers with the same name (e.g. Cookie
),
they will be returned as multiple entries in the array.
addRequestHeader(Header)
,
addRequestHeader(String,String)
public boolean validate()
public int getStatusCode()
public java.lang.String getStatusText()
public org.apache.commons.httpclient.Header[] getResponseHeaders()
public org.apache.commons.httpclient.Header getResponseHeader(java.lang.String headerName)
headerName
- The name of the header to be returned.
public org.apache.commons.httpclient.Header[] getResponseFooters()
public org.apache.commons.httpclient.Header getResponseFooter(java.lang.String footerName)
footerName
- The name of the footer.
public byte[] getResponseBody()
null
is returned. Note that this method does not propagate I/O exceptions.
If an error occurs while reading the body, null
will be returned.
null
if the
body is not available.public java.lang.String getResponseBodyAsString()
String
.
If response body is not available or cannot be read, null is returned.
The raw bytes in the body are converted to a String
using the
character encoding specified in the response's Content-Type header, or
ISO-8859-1 if the response did not specify a character set.
Note that this method does not propagate I/O exceptions.
If an error occurs while reading the body, null
will be returned.
String
, or null
if the body is not available.public java.io.InputStream getResponseBodyAsStream() throws java.io.IOException
null
is returned. Additionally, null
may be returned
if releaseConnection()
has been called or
if this method was called previously and the resulting stream was closed.
null
if it is not available
java.io.IOException
- if an I/O (transport) problem occurspublic boolean hasBeenUsed()
executed
,
but not recycled
.
public int execute(org.apache.commons.httpclient.HttpState state, HttpConnection connection) throws org.apache.commons.httpclient.HttpException, java.io.IOException
HttpConnection
and
HttpState
.
state
- the state
information to associate with this methodconnection
- 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.public void recycle()
releaseConnection()
public void releaseConnection()
After this method is called, getResponseBodyAsStream()
will return
null
, and getResponseBody()
and getResponseBodyAsString()
may return null
.
public void addResponseFooter(org.apache.commons.httpclient.Header footer)
Note: This method is for internal use only and should not be called by external clients.
footer
- the footer to addpublic org.apache.commons.httpclient.StatusLine getStatusLine()
null
if the method has not been executed.
null
if the method has not been executedpublic boolean getDoAuthentication()
setDoAuthentication(boolean)
public void setDoAuthentication(boolean doAuthentication)
doAuthentication
- true to process authentication challenges
automatically, false otherwise.getDoAuthentication()
public void setHttpRecorder(HttpRecorder httpRecorder)
httpRecorder
- HttpRecorder to set and record to.public HttpRecorder getHttpRecorder()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |