|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface HttpMethod
HttpMethod interface represents a request to be sent via a
HTTP connection
and a corresponding response.
Method Summary | |
---|---|
void |
abort()
Aborts the execution of the HTTP method. |
void |
addRequestHeader(Header header)
Adds the specified request header, not overwriting any previous value. |
void |
addRequestHeader(String headerName,
String headerValue)
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()
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. |
AuthState |
getHostAuthState()
Returns the target host authentication state |
HostConfiguration |
getHostConfiguration()
Deprecated. no longer applicable |
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. |
String |
getPath()
Returns the path of the HTTP method. |
AuthState |
getProxyAuthState()
Returns the proxy authentication state |
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. |
InputStream |
getResponseBodyAsStream()
Returns the response body of the HTTP method, if any, as an InputStream. |
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. |
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 executed ,
but not recycled . |
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. |
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(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 |
setParams(HttpMethodParams params)
Assigns HTTP protocol parameters for this method. |
void |
setPath(String path)
Sets the path of the HTTP method. |
void |
setQueryString(NameValuePair[] params)
Sets the query string of this HTTP method. |
void |
setQueryString(String queryString)
Sets the query string of the HTTP method. |
void |
setRequestHeader(Header header)
Sets the specified request header, overwriting any previous value. |
void |
setRequestHeader(String headerName,
String headerValue)
Sets the specified request header, overwriting any previous value. |
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. |
boolean |
validate()
Returns true the method is ready to execute, false otherwise. |
Method Detail |
---|
String getName()
HostConfiguration getHostConfiguration()
null
if none is setvoid setPath(String path)
path
- The path of the HTTP method. The path is expected
to be URL encoded.String getPath()
URI getURI() throws URIException
URIException
- if a URI cannot be constructedvoid setURI(URI uri) throws URIException
uri
- URI to be set
URIException
- if a URI cannot be setvoid setStrictMode(boolean strictMode)
HttpParams.setParameter(String, Object)
to exercise a more granular control over HTTP protocol strictness.
strictMode
- true for strict mode, false otherwiseisStrictMode()
boolean isStrictMode()
HttpParams.setParameter(String, Object)
to exercise a more granular control over HTTP protocol strictness.
setStrictMode(boolean)
void setRequestHeader(String headerName, String headerValue)
headerName
- the header's nameheaderValue
- the header's valuesetRequestHeader(Header)
,
getRequestHeader(String)
,
removeRequestHeader(String)
void setRequestHeader(Header header)
header
- the header to be setsetRequestHeader(String,String)
,
getRequestHeader(String)
,
removeRequestHeader(String)
void addRequestHeader(String headerName, String headerValue)
headerName
- the header's nameheaderValue
- the header's valueaddRequestHeader(Header)
,
getRequestHeader(String)
,
removeRequestHeader(String)
void addRequestHeader(Header header)
header
- the headeraddRequestHeader(String,String)
,
getRequestHeader(String)
,
removeRequestHeader(String)
Header getRequestHeader(String headerName)
headerName
- the header name
void removeRequestHeader(String headerName)
headerName
- the header namevoid removeRequestHeader(Header header)
header
- the headerboolean getFollowRedirects()
void setFollowRedirects(boolean followRedirects)
followRedirects
- true if the method will automatically follow redirects,
false otherwise.void setQueryString(String queryString)
queryString
- the query to be used in the request, with no leading '?' charactergetQueryString()
,
setQueryString(NameValuePair[])
void setQueryString(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)
String getQueryString()
setQueryString(NameValuePair[])
,
setQueryString(String)
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)
Header[] getRequestHeaders(String headerName)
headerName
- the name of the headers to be returned.
boolean validate()
int getStatusCode()
String getStatusText()
Header[] getResponseHeaders()
Header getResponseHeader(String headerName)
headerName
- The name of the header to be returned.
Header[] getResponseHeaders(String headerName)
headerName
- the name of the headers to be returned.
Header[] getResponseFooters()
Header getResponseFooter(String footerName)
footerName
- The name of the footer.
byte[] getResponseBody() throws IOException
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.
IOException
- if an I/O (transport) problem occursString getResponseBodyAsString() throws IOException
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.
IOException
- if an I/O (transport) problem occursInputStream getResponseBodyAsStream() throws 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
IOException
- if an I/O (transport) problem occursboolean hasBeenUsed()
executed
,
but not recycled
.
int execute(HttpState state, HttpConnection connection) throws HttpException, IOException
HttpConnection
and
HttpState
.
state
- the state
information to associate with this methodconnection
- the connection
used to execute
this HTTP method
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.void abort()
execute(HttpState, HttpConnection)
void recycle()
releaseConnection()
void releaseConnection()
After this method is called, getResponseBodyAsStream()
will return
null
, and getResponseBody()
and getResponseBodyAsString()
may return null
.
void addResponseFooter(Header footer)
Note: This method is for internal use only and should not be called by external clients.
footer
- the footer to addStatusLine getStatusLine()
null
if the method has not been executed.
null
if the method has not been executedboolean getDoAuthentication()
setDoAuthentication(boolean)
void setDoAuthentication(boolean doAuthentication)
doAuthentication
- true to process authentication challenges
automatically, false otherwise.getDoAuthentication()
HttpMethodParams getParams()
HTTP protocol parameters
associated with this method.
HttpMethodParams
void setParams(HttpMethodParams params)
HTTP protocol parameters
for this method.
HttpMethodParams
AuthState getHostAuthState()
authentication state
AuthState getProxyAuthState()
authentication state
boolean isRequestSent()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |