Method from org.apache.commons.httpclient.HttpMethod Detail: |
public void abort()
Aborts the execution of the HTTP method. |
public void addRequestHeader(Header header)
Adds the specified request header, not overwriting any previous value.
If the same header is added multiple times, perhaps with different values,
multiple instances of that header will be sent in the HTTP request.
Note that header-name matching is case insensitive. |
public void addRequestHeader(String headerName,
String headerValue)
Adds the specified request header, not overwriting any previous value.
If the same header is added multiple times, perhaps with different values,
multiple instances of that header will be sent in the HTTP request.
Note that header-name matching is case insensitive. |
public void addResponseFooter(Header footer)
|
public int execute(HttpState state,
HttpConnection connection) throws IOException, HttpException
Executes this method using the specified HttpConnection and
HttpState . |
public boolean getDoAuthentication()
Returns true if the HTTP method should automatically handle HTTP
authentication challenges (status code 401, etc.), false otherwise |
public boolean getFollowRedirects()
Returns true if the HTTP method should automatically follow HTTP redirects
(status code 302, etc.), false otherwise. |
public AuthState getHostAuthState()
|
public HostConfiguration getHostConfiguration()Deprecated! no - longer applicable
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. |
public String getName()
Obtains the name of the HTTP method as used in the HTTP request line,
for example "GET" or "POST". |
public HttpMethodParams getParams()
|
public String getPath()
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. |
public AuthState getProxyAuthState()
|
public String getQueryString()
Returns the query string of this HTTP method. |
public Header getRequestHeader(String headerName)
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. |
public Header[] getRequestHeaders()
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. |
public Header[] getRequestHeaders(String headerName)
Returns the request headers with the given name. Note that header-name matching is
case insensitive. |
public byte[] getResponseBody() throws IOException
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. |
public InputStream getResponseBodyAsStream() throws IOException
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 #releaseConnection has been called or
if this method was called previously and the resulting stream was closed. |
public String getResponseBodyAsString() throws IOException
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. |
public Header getResponseFooter(String footerName)
Return the specified response footer. Note that footer-name matching is
case insensitive. |
public Header[] getResponseFooters()
Returns the response footers from the most recent execution of this request. |
public Header getResponseHeader(String headerName)
Returns the specified response header. Note that header-name matching is
case insensitive. |
public Header[] getResponseHeaders()
Returns the response headers from the most recent execution of this request. |
public Header[] getResponseHeaders(String headerName)
Returns the response headers with the given name. Note that header-name matching is
case insensitive. |
public int getStatusCode()
Returns the status code associated with the latest response. |
public StatusLine getStatusLine()
Returns the Status-Line from the most recent response for this method,
or null if the method has not been executed. |
public String getStatusText()
Returns the status text (or "reason phrase") associated with the latest
response. |
public URI getURI() throws URIException
Returns the URI for this method. The URI will be absolute if the host
configuration has been set and relative otherwise. |
public boolean hasBeenUsed()
|
public boolean isRequestSent()
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. |
public boolean isStrictMode()Deprecated! Use - org.apache.commons.httpclient.params.HttpParams#setParameter(String, Object)
to exercise a more granular control over HTTP protocol strictness.
Returns the value of the strict mode flag. |
public void recycle()Deprecated! no - longer supported and will be removed in the future
version of HttpClient
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. |
public void releaseConnection()
Releases the connection being used by this HTTP method. In particular the
connection is used to read the response (if there is one) and will be held
until the response has been read. If the connection can be reused by other
HTTP methods it is NOT closed at this point.
After this method is called, #getResponseBodyAsStream will return
null , and #getResponseBody and #getResponseBodyAsString
may return null . |
public void removeRequestHeader(String headerName)
Removes all request headers with the given name.
Note that header-name matching is case insensitive. |
public void removeRequestHeader(Header header)
Removes the given request header. |
public void setDoAuthentication(boolean doAuthentication)
Sets whether or not the HTTP method should automatically handle HTTP
authentication challenges (status code 401, etc.) |
public void setFollowRedirects(boolean followRedirects)
Sets whether or not the HTTP method should automatically follow HTTP redirects
(status code 302, etc.) |
public void setParams(HttpMethodParams params)
|
public 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). |
public 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). The string must not include an initial '?' character. |
public void setQueryString(NameValuePair[] params)
Sets the query string of this HTTP method. The pairs are encoded as UTF-8 characters.
To use a different charset the parameters can be encoded manually using EncodingUtil
and set as a single String. |
public void setRequestHeader(Header header)
Sets the specified request header, overwriting any
previous value.
Note that header-name matching is case insensitive. |
public void setRequestHeader(String headerName,
String headerValue)
Sets the specified request header, overwriting any
previous value.
Note that header-name matching is case insensitive. |
public void setStrictMode(boolean strictMode)Deprecated! Use - org.apache.commons.httpclient.params.HttpParams#setParameter(String, Object)
to exercise a more granular control over HTTP protocol strictness.
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. |
public void setURI(URI uri) throws URIException
Sets the URI for this method. |
public boolean validate()
Returns true the method is ready to execute, false otherwise. |