| org.apache.commons.httpclient.HttpMethod
All known Subclasses: org.apache.commons.httpclient.HttpMethodBase,
HttpMethod | public interface HttpMethod (Code) | |
HttpMethod interface represents a request to be sent via a
HttpConnection HTTP connection and a corresponding response.
author: Remy Maucherat author: Rod Waldhoff author: Jeff Dever author: Mike Bowler author: Oleg Kalnichevski version: $Revision: 480424 $ $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $ since: 1.0 |
Method Summary | |
void | abort() Aborts the execution of the HTTP method. | void | addRequestHeader(String headerName, String headerValue) Adds the specified request header, not overwriting any previous value. | void | addRequestHeader(Header header) Adds the specified request header, not overwriting any previous value. | void | addResponseFooter(Header footer) Add a footer to this method's response. | int | execute(HttpState state, HttpConnection connection) Executes this method using the specified HttpConnection and
HttpState . | boolean | getDoAuthentication() | boolean | getFollowRedirects() Returns true if the HTTP method should automatically follow HTTP redirects
(status code 302, etc.), false otherwise. | public AuthState | getHostAuthState() | HostConfiguration | getHostConfiguration() Gets the host configuration for this method. | String | getName() Obtains the name of the HTTP method as used in the HTTP request line,
for example "GET" or "POST". | public HttpMethodParams | getParams() Returns
HttpMethodParams HTTP protocol parameters associated with this method. | String | getPath() Returns the path of the HTTP method. | public AuthState | getProxyAuthState() | String | getQueryString() Returns the query string of this HTTP method. | Header | getRequestHeader(String headerName) Gets the request header with the given name. | Header[] | getRequestHeaders() Returns the current request headers for this HTTP method. | Header[] | getRequestHeaders(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.
If the method has not yet been executed or the response has no body, null
is returned. | InputStream | getResponseBodyAsStream() Returns the response body of the HTTP method, if any, as an InputStream.
If the response had no body or the method has not yet been executed,
null is returned. | String | getResponseBodyAsString() Returns the response body of the HTTP method, if any, as a
String . | Header | getResponseFooter(String footerName) Return the specified response footer. | Header[] | getResponseFooters() Returns the response footers from the most recent execution of this request.
an array containing the response footers in the order that theyappeared in the response. | Header | getResponseHeader(String headerName) Returns the specified response header. | Header[] | getResponseHeaders() Returns the response headers from the most recent execution of this request. | Header[] | getResponseHeaders(String headerName) Returns the response headers with the given name. | int | getStatusCode() Returns the status code associated with the latest response. | StatusLine | getStatusLine() Returns the Status-Line from the most recent response for this method,
or null if the method has not been executed. | String | getStatusText() Returns the status text (or "reason phrase") associated with the latest
response. | URI | getURI() Returns the URI for this method. | boolean | hasBeenUsed() Returns true if the HTTP method has been already
HttpMethod.execute executed ,
but not
HttpMethod.recycle recycled . | boolean | isRequestSent() Returns true if the HTTP has been transmitted to the target
server in its entirety, false otherwise. | boolean | isStrictMode() Returns the value of the strict mode flag. | void | recycle() Recycles the HTTP method so that it can be used again.
Note that all of the instance variables will be reset
once this method has been called. | void | releaseConnection() Releases the connection being used by this HTTP method. | void | removeRequestHeader(String headerName) Removes all request headers with the given name. | void | removeRequestHeader(Header header) Removes the given request header. | void | setDoAuthentication(boolean doAuthentication) | void | setFollowRedirects(boolean followRedirects) | public void | setParams(HttpMethodParams params) Assigns
HttpMethodParams HTTP protocol parameters for this method. | void | setPath(String path) Sets the path of the HTTP method.
It is responsibility of the caller to ensure that the path is
properly encoded (URL safe).
Parameters: path - The path of the HTTP method. | void | setQueryString(String queryString) Sets the query string of the HTTP method.
It is responsibility of the caller to ensure that the path is
properly encoded (URL safe). | void | setQueryString(NameValuePair[] params) Sets the query string of this HTTP method. | void | setRequestHeader(String headerName, String headerValue) Sets the specified request header, overwriting any
previous value. | void | setRequestHeader(Header header) Sets the specified request header, overwriting any
previous value. | void | setStrictMode(boolean strictMode) Defines how strictly the method follows the HTTP protocol specification. | void | setURI(URI uri) Sets the URI for this method. | boolean | validate() Returns true the method is ready to execute, false otherwise. |
addResponseFooter | void addResponseFooter(Header footer)(Code) | | Add a footer to this method's response.
Note: This method is for
internal use only and should not be called by external clients.
Parameters: footer - the footer to add since: 2.0 |
execute | int execute(HttpState state, HttpConnection connection) throws HttpException, IOException(Code) | | Executes this method using the specified HttpConnection and
HttpState .
Parameters: state - the HttpState state information to associate with this method Parameters: connection - the HttpConnection connection used to executethis HTTP method throws: IOException - If an I/O (transport) error occurs. Some transport exceptionscan be recovered from. throws: HttpException - If a protocol exception occurs. Usually protocol exceptions cannot be recovered from. the integer status code if one was obtained, or -1 |
getDoAuthentication | boolean getDoAuthentication()(Code) | | Returns true if the HTTP method should automatically handle HTTP
authentication challenges (status code 401, etc.), false otherwise
true if authentication challenges will be processed automatically, false otherwise. since: 2.0 See Also: HttpMethod.setDoAuthentication(boolean) |
getFollowRedirects | boolean getFollowRedirects()(Code) | | Returns true if the HTTP method should automatically follow HTTP redirects
(status code 302, etc.), false otherwise.
true if the method will automatically follow HTTP redirects, false otherwise |
getHostAuthState | public AuthState getHostAuthState()(Code) | | Returns the target host
AuthState authentication state host authentication state since: 3.0 |
getHostConfiguration | HostConfiguration getHostConfiguration()(Code) | | Gets the host configuration for this method. The configuration specifies
the server, port, protocol, and proxy server via which this method will
send its HTTP request.
the HostConfiguration or null if none is set |
getName | String getName()(Code) | | Obtains the name of the HTTP method as used in the HTTP request line,
for example "GET" or "POST".
the name of this method |
getPath | String getPath()(Code) | | Returns the path of the 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.
the path of the HTTP method, in URL encoded form |
getProxyAuthState | public AuthState getProxyAuthState()(Code) | | Returns the proxy
AuthState authentication state host authentication state since: 3.0 |
getRequestHeader | Header getRequestHeader(String headerName)(Code) | | Gets the request header with the given name.
If there are multiple headers with the same name,
there values will be combined with the ',' separator as specified by RFC2616.
Note that header-name matching is case insensitive.
Parameters: headerName - the header name the header |
getRequestHeaders | Header[] getRequestHeaders()(Code) | | Returns the current request headers for this HTTP method. The returned headers
will be in the same order that they were added with addRequestHeader .
If there are multiple request headers with the same name (e.g. Cookie ),
they will be returned as multiple entries in the array.
an array containing all of the request headers See Also: HttpMethod.addRequestHeader(Header) See Also: HttpMethod.addRequestHeader(String,String) |
getRequestHeaders | Header[] getRequestHeaders(String headerName)(Code) | | Returns the request headers with the given name. Note that header-name matching is
case insensitive.
Parameters: headerName - the name of the headers to be returned. an array of zero or more headers since: 3.0 |
getResponseBody | byte[] getResponseBody() throws IOException(Code) | | Returns the response body of the HTTP method, if any, as an array of bytes.
If the method has not yet been executed or the response has no body, 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.
The response body, or null if thebody is not available. throws: IOException - if an I/O (transport) problem occurs |
getResponseBodyAsStream | InputStream getResponseBodyAsStream() throws IOException(Code) | | Returns the response body of the HTTP method, if any, as an InputStream.
If the response had no body or the method has not yet been executed,
null is returned. Additionally, null may be returned
if
HttpMethod.releaseConnection has been called or
if this method was called previously and the resulting stream was closed.
The response body, or null if it is not available throws: IOException - if an I/O (transport) problem occurs |
getResponseBodyAsString | String getResponseBodyAsString() throws IOException(Code) | | Returns the response body of the HTTP method, if any, as a
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.
The response body converted to a String , or null if the body is not available. throws: IOException - if an I/O (transport) problem occurs |
getResponseFooter | Header getResponseFooter(String footerName)(Code) | | Return the specified response footer. Note that footer-name matching is
case insensitive.
Parameters: footerName - The name of the footer. The response footer. |
getResponseFooters | Header[] getResponseFooters()(Code) | | Returns the response footers from the most recent execution of this request.
an array containing the response footers in the order that theyappeared in the response. If the response had no footers,an empty array will be returned. |
getResponseHeader | Header getResponseHeader(String headerName)(Code) | | Returns the specified response header. Note that header-name matching is
case insensitive.
Parameters: headerName - The name of the header to be returned. The specified response header. If the repsonse contained multipleinstances of the header, its values will be combined using the ','separator as specified by RFC2616. |
getResponseHeaders | Header[] getResponseHeaders()(Code) | | Returns the response headers from the most recent execution of this request.
A newly-created array containing all of the response headers, in the order in which they appeared in the response. |
getResponseHeaders | Header[] getResponseHeaders(String headerName)(Code) | | Returns the response headers with the given name. Note that header-name matching is
case insensitive.
Parameters: headerName - the name of the headers to be returned. an array of zero or more headers since: 3.0 |
getStatusCode | int getStatusCode()(Code) | | Returns the status code associated with the latest response.
The status code from the most recent execution of this method.If the method has not yet been executed, the result is undefined. |
getStatusLine | StatusLine getStatusLine()(Code) | | Returns the Status-Line from the most recent response for this method,
or null if the method has not been executed.
the status line, or null if the method has not been executed since: 2.0 |
getStatusText | String getStatusText()(Code) | | Returns the status text (or "reason phrase") associated with the latest
response.
The status text from the most recent execution of this method.If the method has not yet been executed, the result is undefined. |
getURI | URI getURI() throws URIException(Code) | | Returns the URI for this method. The URI will be absolute if the host
configuration has been set and relative otherwise.
the URI for this method throws: URIException - if a URI cannot be constructed |
hasBeenUsed | boolean hasBeenUsed()(Code) | | Returns true if the HTTP method has been already
HttpMethod.execute executed ,
but not
HttpMethod.recycle recycled .
true if the method has been executed, false otherwise |
isRequestSent | boolean isRequestSent()(Code) | | Returns true if the HTTP has been transmitted to the target
server in its entirety, false otherwise. This flag can be useful
for recovery logic. If the request has not been transmitted in its entirety,
it is safe to retry the failed method.
true if the request has been sent, false otherwise |
recycle | void recycle()(Code) | | Recycles the HTTP method so that it can be used again.
Note that all of the instance variables will be reset
once this method has been called. This method will also
release the connection being used by this HTTP method.
See Also: HttpMethod.releaseConnection() |
removeRequestHeader | void removeRequestHeader(String headerName)(Code) | | Removes all request headers with the given name.
Note that header-name matching is case insensitive.
Parameters: headerName - the header name |
removeRequestHeader | void removeRequestHeader(Header header)(Code) | | Removes the given request header.
Parameters: header - the header since: 3.0 |
setDoAuthentication | void setDoAuthentication(boolean doAuthentication)(Code) | | Sets whether or not the HTTP method should automatically handle HTTP
authentication challenges (status code 401, etc.)
Parameters: doAuthentication - true to process authentication challengesautomatically, false otherwise. since: 2.0 See Also: HttpMethod.getDoAuthentication() |
setFollowRedirects | void setFollowRedirects(boolean followRedirects)(Code) | | Sets whether or not the HTTP method should automatically follow HTTP redirects
(status code 302, etc.)
Parameters: followRedirects - true if the method will automatically follow redirects,false otherwise. |
setPath | void setPath(String path)(Code) | | Sets the path of the HTTP method.
It is responsibility of the caller to ensure that the path is
properly encoded (URL safe).
Parameters: path - The path of the HTTP method. The path is expectedto be URL encoded. |
setQueryString | void setQueryString(String queryString)(Code) | | Sets the query string of the HTTP method.
It is responsibility of the caller to ensure that the path is
properly encoded (URL safe). The string must not include an initial '?' character.
Parameters: queryString - the query to be used in the request, with no leading '?' character See Also: HttpMethod.getQueryString() See Also: HttpMethod.setQueryString(NameValuePair[]) |
setStrictMode | void setStrictMode(boolean strictMode)(Code) | | Defines how strictly the method follows the HTTP protocol specification.
(See RFC 2616 and other relevant RFCs.) In the strict mode the method precisely
implements the requirements of the specification, whereas in non-strict mode
it attempts to mimic the exact behaviour of commonly used HTTP agents,
which many HTTP servers expect.
Parameters: strictMode - true for strict mode, false otherwiseorg.apache.commons.httpclient.params.HttpParams.setParameter(StringObject) See Also: HttpMethod.isStrictMode() |
setURI | void setURI(URI uri) throws URIException(Code) | | Sets the URI for this method.
Parameters: uri - URI to be set throws: URIException - if a URI cannot be set since: 3.0 |
validate | boolean validate()(Code) | | Returns true the method is ready to execute, false otherwise.
true if the method is ready to execute, false otherwise. |
|
|