| java.lang.Object org.apache.commons.httpclient.HttpMethodBase
HttpMethodBase | abstract public class HttpMethodBase implements HttpMethod(Code) | | An abstract base implementation of HttpMethod.
At minimum, subclasses will need to override:
When a method requires additional request headers, subclasses will typically
want to override:
When a method expects specific response headers, subclasses may want to
override:
author: Remy Maucherat author: Rodney Waldhoff author: Sean C. Sullivan author: dIon Gillard author: Jeff Dever author: Davanum Srinivas author: Ortwin Glueck author: Eric Johnson author: Michael Becke author: Oleg Kalnichevski author: Mike Bowler author: Gary Gregory author: Christian Kohlschuetter version: $Revision: 4946 $ $Date: 2007-02-28 23:35:32 +0000 (Wed, 28 Feb 2007) $ |
Constructor Summary | |
public | HttpMethodBase() No-arg constructor. | public | HttpMethodBase(String uri) Constructor specifying a URI.
It is responsibility of the caller to ensure that URI elements
(path & query parameters) are properly encoded (URL safe).
Parameters: uri - either an absolute or relative URI. |
Method Summary | |
public void | abort() Aborts the execution of this method. | protected void | addCookieRequestHeader(HttpState state, HttpConnection conn) Generates Cookie request headers for those
Cookie cookie s
that match the given host, port and path.
Parameters: state - the HttpState state information associated with this method Parameters: conn - the HttpConnection connection used to executethis HTTP method throws: IOException - if an I/O (transport) error occurs. | protected void | addHostRequestHeader(HttpState state, HttpConnection conn) Generates Host request header, as long as no Host request
header already exists.
Parameters: state - the HttpState state information associated with this method Parameters: conn - the HttpConnection connection used to executethis HTTP method throws: IOException - if an I/O (transport) error occurs. | protected void | addProxyConnectionHeader(HttpState state, HttpConnection conn) Generates Proxy-Connection: Keep-Alive request header when
communicating via a proxy server.
Parameters: state - the HttpState state information associated with this method Parameters: conn - the HttpConnection connection used to executethis HTTP method throws: IOException - if an I/O (transport) error occurs. | public void | addRequestHeader(Header header) Adds the specified request header, NOT overwriting any previous value. | public void | addRequestHeader(String headerName, String headerValue) Adds the specified request header, NOT overwriting any previous value. | protected void | addRequestHeaders(HttpState state, HttpConnection conn) Generates all the required request
Header header s
to be submitted via the given
HttpConnection connection .
This implementation adds User-Agent, Host,
Cookie, Authorization, Proxy-Authorization
and Proxy-Connection 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.
Parameters: state - the HttpState state information associated with this method Parameters: conn - the HttpConnection connection used to executethis HTTP method throws: IOException - if an I/O (transport) error occurs. | public void | addResponseFooter(Header footer) Use this method internally to add footers. | protected void | addUserAgentRequestHeader(HttpState state, HttpConnection conn) Generates default User-Agent request header, as long as no
User-Agent request header already exists.
Parameters: state - the HttpState state information associated with this method Parameters: conn - the HttpConnection connection used to executethis HTTP method throws: IOException - if an I/O (transport) error occurs. | protected void | checkNotUsed() Throws an
IllegalStateException if the HTTP method has been already
HttpMethodBase.execute executed , but not
HttpMethodBase.recycle recycled . | protected void | checkUsed() Throws an
IllegalStateException if the HTTP method has not been
HttpMethodBase.execute executed since last
HttpMethodBase.recycle recycle . | public int | execute(HttpState state, HttpConnection conn) Executes this method using the specified HttpConnection and
HttpState . | void | fakeResponse(StatusLine statusline, HeaderGroup responseheaders, 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 String | generateRequestLine(HttpConnection connection, String name, String requestPath, String query, String version) Generates HTTP request line according to the specified attributes.
Parameters: connection - the HttpConnection connection used to executethis HTTP method Parameters: name - the method name generate a request for Parameters: requestPath - the path string for the request Parameters: query - the query string for the request Parameters: version - the protocol version to use (e.g. | public String | getAuthenticationRealm() Returns authentication realm, if it has been used during authentication process. | protected String | getContentCharSet(Header contentheader) Returns the character set from the Content-Type header.
Parameters: contentheader - The content header. | public boolean | getDoAuthentication() | public HttpVersion | getEffectiveVersion() | 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() Returns the
HostConfiguration host configuration . | public MethodRetryHandler | getMethodRetryHandler() | abstract 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() Returns
HttpMethodParams HTTP protocol parameters associated with this method. | public String | getPath() Gets the path of this HTTP method. | public AuthState | getProxyAuthState() | public String | getProxyAuthenticationRealm() Returns proxy authentication realm, if it has been used during authentication process. | public String | getQueryString() Gets the query string of this HTTP method. | public int | getRecoverableExceptionCount() | public String | getRequestCharSet() Returns the character encoding of the request from the Content-Type header. | public Header | getRequestHeader(String headerName) Returns the specified request header. | protected HeaderGroup | getRequestHeaderGroup() Gets the
HeaderGroup header group storing the request headers. | public Header[] | getRequestHeaders() | public Header[] | getRequestHeaders(String headerName) | public byte[] | getResponseBody() Returns the response body of the HTTP method, if any, as an array of bytes.
If response body is not available or cannot be read, returns null
Note: This will cause the entire response body to be buffered in memory. | public InputStream | getResponseBodyAsStream() Returns the response body of the HTTP method, if any, as an
InputStream . | public String | getResponseBodyAsString() Returns the response body of the HTTP method, if any, as a
String . | public String | getResponseCharSet() Returns the character encoding of the response from the Content-Type header. | public long | getResponseContentLength() Return the length (in bytes) of the response body, as specified in a
Content-Length header.
Return -1 when the content-length is unknown.
content length, if Content-Length header is available. | public Header | getResponseFooter(String footerName) Gets the response footer associated with the given name.
Footer name matching is case insensitive.
null will be returned if either footerName is
null or there is no matching footer for footerName
or there are no footers available. | public Header[] | getResponseFooters() Returns an array of the response footers that the HTTP method currently has
in the order in which they were read. | public Header | getResponseHeader(String headerName) Gets the response header associated with the given name. | protected HeaderGroup | getResponseHeaderGroup() Gets the
HeaderGroup header group storing the response headers. | public Header[] | getResponseHeaders(String headerName) | public Header[] | getResponseHeaders() Returns an array of the response headers that the HTTP method currently has
in the order in which they were read. | protected InputStream | getResponseStream() Returns a stream from which the body of the current response may be read. | protected HeaderGroup | getResponseTrailerHeaderGroup() Gets the
HeaderGroup header group storing the response trailer headers
as per RFC 2616 section 3.6.1. | public int | getStatusCode() Returns the response status code. | public StatusLine | getStatusLine() Provides access to the response status line. | public String | getStatusText() Returns the status text (or "reason phrase") associated with the latest
response. | public URI | getURI() | public boolean | hasBeenUsed() Returns true if the HTTP method has been already
HttpMethodBase.execute executed ,
but not
HttpMethodBase.recycle recycled . | public boolean | isAborted() | protected boolean | isConnectionCloseForced() Tests if the connection should be force-closed when no longer needed. | public 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. | public boolean | isRequestSent() Returns true if the HTTP has been transmitted to the target
server in its entirety, false otherwise. | public boolean | isStrictMode() | protected void | processResponseBody(HttpState state, HttpConnection conn) This method is invoked immediately after
HttpMethodBase.readResponseBody(HttpState,HttpConnection) and can be overridden by
sub-classes in order to provide custom body processing. | protected void | processResponseHeaders(HttpState state, HttpConnection conn) This method is invoked immediately after
HttpMethodBase.readResponseHeaders(HttpState,HttpConnection) and can be overridden by
sub-classes in order to provide custom response headers processing. | protected void | processStatusLine(HttpState state, HttpConnection conn) This method is invoked immediately after
HttpMethodBase.readStatusLine(HttpState,HttpConnection) and can be overridden by
sub-classes in order to provide custom response status line processing. | protected void | readResponse(HttpState state, HttpConnection conn) Reads the response from the given
HttpConnection connection .
The response is processed as the following sequence of actions:
-
HttpMethodBase.readStatusLine(HttpState,HttpConnection) is
invoked to read the request line.
-
HttpMethodBase.processStatusLine(HttpState,HttpConnection) is invoked, allowing the method to process the status line if
desired.
-
HttpMethodBase.readResponseHeaders(HttpState,HttpConnection) is invoked to read
the associated headers.
-
HttpMethodBase.processResponseHeaders(HttpState,HttpConnection) is invoked, allowing
the method to process the headers if desired.
-
HttpMethodBase.readResponseBody(HttpState,HttpConnection) is
invoked to read the associated body (if any).
-
HttpMethodBase.processResponseBody(HttpState,HttpConnection) is invoked, allowing the
method to process the response body if desired.
Subclasses may want to override one or more of the above methods to to
customize the processing. | protected void | readResponseBody(HttpState state, HttpConnection conn) Read the response body from the given
HttpConnection .
The current implementation wraps the socket level stream with
an appropriate stream for the type of response (chunked, content-length,
or auto-close). | protected void | readResponseHeaders(HttpState state, HttpConnection conn) Reads the response headers from the given
HttpConnection 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)
Parameters: state - the HttpState state information associated with this method Parameters: conn - the HttpConnection connection used to executethis HTTP method throws: IOException - if an I/O (transport) error occurs. | protected void | readStatusLine(HttpState state, HttpConnection conn) Read the status line from the given
HttpConnection , setting my
HttpMethodBase.getStatusCode status code and
HttpMethodBase.getStatusText statustext .
Subclasses may want to override this method to to customize the
processing.
Parameters: state - the HttpState state information associated with this method Parameters: conn - the HttpConnection connection used to executethis HTTP method throws: IOException - if an I/O (transport) error occurs. | public 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. | public void | releaseConnection() Releases the connection being used by this HTTP method. | public void | removeRequestHeader(String headerName) Remove the request header associated with the given name. | public void | removeRequestHeader(Header header) Removes the given request header. | 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. | public void | setDoAuthentication(boolean doAuthentication) | public void | setFollowRedirects(boolean followRedirects) | public void | setHostConfiguration(HostConfiguration hostconfig) Sets the
HostConfiguration host configuration . | public void | setHttp11(boolean http11) Sets whether version 1.1 of the HTTP protocol should be used per default. | public void | setMethodRetryHandler(MethodRetryHandler handler) | public void | setParams(HttpMethodParams params) Assigns
HttpMethodParams HTTP protocol parameters for this method. | 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).
Parameters: path - the path of the HTTP method. | public void | setQueryString(String queryString) Sets the query string of this HTTP method. | public void | setQueryString(NameValuePair[] params) Sets the query string of this HTTP method. | public void | setRequestHeader(String headerName, String headerValue) Set the specified request header, overwriting any previous value. | public void | setRequestHeader(Header header) Sets the specified request header, overwriting any previous value. | protected void | setResponseStream(InputStream responseStream) Sets the response stream. | public void | setStrictMode(boolean strictMode) Defines how strictly HttpClient follows the HTTP protocol specification
(RFC 2616 and other relevant RFCs). | public void | setURI(URI uri) Sets the URI for this method. | protected boolean | shouldCloseConnection(HttpConnection conn) Tests if the connection should be closed after the method has been executed. | public boolean | validate() Returns true the method is ready to execute, false otherwise. | protected void | writeRequest(HttpState state, HttpConnection conn)
Sends the request via the given
HttpConnection connection .
The request is written as the following sequence of actions:
-
HttpMethodBase.writeRequestLine(HttpState,HttpConnection) is invoked to
write the request line.
-
HttpMethodBase.writeRequestHeaders(HttpState,HttpConnection) is invoked
to write the associated headers.
-
\r\n is sent to close the head part of the request.
-
HttpMethodBase.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. | protected boolean | writeRequestBody(HttpState state, HttpConnection conn) Writes the request body to the given
HttpConnection 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.
Parameters: state - the HttpState state information associated with this method Parameters: conn - the HttpConnection connection used to executethis HTTP method true throws: IOException - if an I/O (transport) error occurs. | protected void | writeRequestHeaders(HttpState state, HttpConnection conn) Writes the request headers to the given
HttpConnection connection .
This implementation invokes
HttpMethodBase.addRequestHeaders(HttpState,HttpConnection) ,
and then writes each header to the request stream.
Subclasses may want to override this method to to customize the
processing.
Parameters: state - the HttpState state information associated with this method Parameters: conn - the HttpConnection connection used to executethis HTTP method throws: IOException - if an I/O (transport) error occurs. | protected void | writeRequestLine(HttpState state, HttpConnection conn) Writes the request line to the given
HttpConnection connection .
Subclasses may want to override this method to to customize the
processing.
Parameters: state - the HttpState state information associated with this method Parameters: conn - the HttpConnection connection used to executethis HTTP method throws: IOException - if an I/O (transport) error occurs. |
HttpMethodBase | public HttpMethodBase()(Code) | | No-arg constructor.
|
abort | public void abort()(Code) | | Aborts the execution of this method.
since: 3.0 |
addCookieRequestHeader | protected void addCookieRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException(Code) | | Generates Cookie request headers for those
Cookie cookie s
that match the given host, port and path.
Parameters: state - the HttpState state information associated with this method Parameters: conn - 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. |
addHostRequestHeader | protected void addHostRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException(Code) | | Generates Host request header, as long as no Host request
header already exists.
Parameters: state - the HttpState state information associated with this method Parameters: conn - 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. |
addProxyConnectionHeader | protected void addProxyConnectionHeader(HttpState state, HttpConnection conn) throws IOException, HttpException(Code) | | Generates Proxy-Connection: Keep-Alive request header when
communicating via a proxy server.
Parameters: state - the HttpState state information associated with this method Parameters: conn - 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. |
addRequestHeader | public void addRequestHeader(Header header)(Code) | | Adds the specified request header, NOT overwriting any previous value.
Note that header-name matching is case insensitive.
Parameters: header - the header to add to the request |
addRequestHeader | public void addRequestHeader(String headerName, String headerValue)(Code) | | Adds the specified request header, NOT overwriting any previous value.
Note that header-name matching is case insensitive.
Parameters: headerName - the header's name Parameters: headerValue - the header's value |
addRequestHeaders | protected void addRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException(Code) | | Generates all the required request
Header header s
to be submitted via the given
HttpConnection connection .
This implementation adds User-Agent, Host,
Cookie, Authorization, Proxy-Authorization
and Proxy-Connection 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.
Parameters: state - the HttpState state information associated with this method Parameters: conn - 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. See Also: HttpMethodBase.writeRequestHeaders |
addResponseFooter | public void addResponseFooter(Header footer)(Code) | | Use this method internally to add footers.
Parameters: footer - The footer to add. |
addUserAgentRequestHeader | protected void addUserAgentRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException(Code) | | Generates default User-Agent request header, as long as no
User-Agent request header already exists.
Parameters: state - the HttpState state information associated with this method Parameters: conn - 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. |
execute | public int execute(HttpState state, HttpConnection conn) throws HttpException, IOException(Code) | | Executes this method using the specified HttpConnection and
HttpState .
Parameters: state - HttpState state information to associate with thisrequest. Must be non-null. Parameters: conn - the HttpConnection connection to used to executethis HTTP method. Must be non-null. the integer status code if one was obtained, or -1 throws: IOException - if an I/O (transport) error occurs throws: HttpException - if a protocol exception occurs. |
fakeResponse | void fakeResponse(StatusLine statusline, HeaderGroup responseheaders, InputStream responseStream)(Code) | | 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.
TODO: Remove this crap as soon as possible
|
generateRequestLine | protected static String generateRequestLine(HttpConnection connection, String name, String requestPath, String query, String version)(Code) | | Generates HTTP request line according to the specified attributes.
Parameters: connection - the HttpConnection connection used to executethis HTTP method Parameters: name - the method name generate a request for Parameters: requestPath - the path string for the request Parameters: query - the query string for the request Parameters: version - the protocol version to use (e.g. HTTP/1.0) HTTP request line |
getAuthenticationRealm | public String getAuthenticationRealm()(Code) | | Returns authentication realm, if it has been used during authentication process.
Otherwise returns null.
authentication realm |
getContentCharSet | protected String getContentCharSet(Header contentheader)(Code) | | Returns the character set from the Content-Type header.
Parameters: contentheader - The content header. String The character set. |
getDoAuthentication | public 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 |
getEffectiveVersion | public HttpVersion getEffectiveVersion()(Code) | | Returns the HTTP version used with this method (may be null
if undefined, that is, the method has not been executed)
HTTP version. since: 3.0 |
getFollowRedirects | public 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 | public HostConfiguration getHostConfiguration()(Code) | | Returns the
HostConfiguration host configuration .
the host configuration |
getMethodRetryHandler | public MethodRetryHandler getMethodRetryHandler()(Code) | | Returns the
MethodRetryHandler retry handler for this HTTP method
the methodRetryHandlerHttpMethodParams |
getName | abstract public 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 |
getParams | public HttpMethodParams getParams()(Code) | | Returns
HttpMethodParams HTTP protocol parameters associated with this method.
HTTP parameters. since: 3.0 |
getPath | public String getPath()(Code) | | Gets the path of this 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 to request or "/" if the path is blank. |
getProxyAuthState | public AuthState getProxyAuthState()(Code) | | Returns the proxy
AuthState authentication state host authentication state since: 3.0 |
getProxyAuthenticationRealm | public String getProxyAuthenticationRealm()(Code) | | Returns proxy authentication realm, if it has been used during authentication process.
Otherwise returns null.
proxy authentication realm |
getQueryString | public String getQueryString()(Code) | | Gets the query string of this HTTP method.
The query string |
getRecoverableExceptionCount | public int getRecoverableExceptionCount()(Code) | | The number of recoverable exceptions handled by the method. |
getRequestCharSet | public String getRequestCharSet()(Code) | | Returns the character encoding of the request from the Content-Type header.
String The character set. |
getRequestHeader | public Header getRequestHeader(String headerName)(Code) | | Returns the specified request header. Note that header-name matching is
case insensitive. null will be returned if either
headerName is null or there is no matching header for
headerName.
Parameters: headerName - The name of the header to be returned. The specified request header. since: 3.0 |
getRequestHeaderGroup | protected HeaderGroup getRequestHeaderGroup()(Code) | | Gets the
HeaderGroup header group storing the request headers.
a HeaderGroup since: 2.0beta1 |
getRequestHeaders | public Header[] getRequestHeaders()(Code) | | Returns an array of the requests headers that the HTTP method currently has
an array of my request headers. |
getRequestHeaders | public Header[] getRequestHeaders(String headerName)(Code) | | See Also: org.apache.commons.httpclient.HttpMethod.getRequestHeaders(java.lang.String) |
getResponseBody | public byte[] getResponseBody() throws IOException(Code) | | Returns the response body of the HTTP method, if any, as an array of bytes.
If response body is not available or cannot be read, returns null
Note: This will cause the entire response body to be buffered in memory. A
malicious server may easily exhaust all the VM memory. It is strongly
recommended, to use getResponseAsStream if the content length of the response
is unknown or resonably large.
The response body. throws: IOException - If an I/O (transport) problem occurs while obtaining the response body. |
getResponseBodyAsStream | public InputStream getResponseBodyAsStream() throws IOException(Code) | | Returns the response body of the HTTP method, if any, as an
InputStream .
If response body is not available, returns null
The response body throws: IOException - If an I/O (transport) problem occurs while obtaining the response body. |
getResponseBodyAsString | public 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, returns null
The string conversion on the data is done using the character encoding specified
in Content-Type header.
Note: This will cause the entire response body to be buffered in memory. A
malicious server may easily exhaust all the VM memory. It is strongly
recommended, to use getResponseAsStream if the content length of the response
is unknown or resonably large.
The response body. throws: IOException - If an I/O (transport) problem occurs while obtaining the response body. |
getResponseCharSet | public String getResponseCharSet()(Code) | | Returns the character encoding of the response from the Content-Type header.
String The character set. |
getResponseContentLength | public long getResponseContentLength()(Code) | | Return the length (in bytes) of the response body, as specified in a
Content-Length header.
Return -1 when the content-length is unknown.
content length, if Content-Length header is available. 0 indicates that the request has no body.If Content-Length header is not present, the method returns -1. |
getResponseFooter | public Header getResponseFooter(String footerName)(Code) | | Gets the response footer associated with the given name.
Footer name matching is case insensitive.
null will be returned if either footerName is
null or there is no matching footer for footerName
or there are no footers available. If there are multiple footers
with the same name, there values will be combined with the ',' separator
as specified by RFC2616.
Parameters: footerName - the footer name to match the matching footer |
getResponseFooters | public Header[] getResponseFooters()(Code) | | Returns an array of the response footers that the HTTP method currently has
in the order in which they were read.
an array of footers |
getResponseHeader | public Header getResponseHeader(String headerName)(Code) | | Gets the response header associated with the given name. Header name
matching is case insensitive. null will be returned if either
headerName is null or there is no matching header for
headerName.
Parameters: headerName - the header name to match the matching header |
getResponseHeaderGroup | protected HeaderGroup getResponseHeaderGroup()(Code) | | Gets the
HeaderGroup header group storing the response headers.
a HeaderGroup since: 2.0beta1 |
getResponseHeaders | public Header[] getResponseHeaders(String headerName)(Code) | | See Also: org.apache.commons.httpclient.HttpMethod.getResponseHeaders(java.lang.String) since: 3.0 |
getResponseHeaders | public Header[] getResponseHeaders()(Code) | | Returns an array of the response headers that the HTTP method currently has
in the order in which they were read.
an array of response headers. |
getResponseStream | protected InputStream getResponseStream()(Code) | | Returns a stream from which the body of the current response may be read.
If the method has not yet been executed, if responseBodyConsumed
has been called, or if the stream returned by a previous call has been closed,
null will be returned.
the current response stream |
getResponseTrailerHeaderGroup | protected HeaderGroup getResponseTrailerHeaderGroup()(Code) | | Gets the
HeaderGroup header group storing the response trailer headers
as per RFC 2616 section 3.6.1.
a HeaderGroup since: 2.0beta1 |
getStatusCode | public int getStatusCode()(Code) | | Returns the response status code.
the status code associated with the latest response. |
getStatusLine | public StatusLine getStatusLine()(Code) | | Provides access to the response status line.
the status line object from the latest response. since: 2.0 |
getStatusText | public String getStatusText()(Code) | | Returns the status text (or "reason phrase") associated with the latest
response.
The status text. |
getURI | public URI getURI() throws URIException(Code) | | Returns the URI of the HTTP method
The URI throws: URIException - If the URI cannot be created. See Also: org.apache.commons.httpclient.HttpMethod.getURI |
isAborted | public boolean isAborted()(Code) | | Tests whether the execution of this method has been aborted
true if the execution of this method has been aborted,false otherwise since: 3.0 |
isConnectionCloseForced | protected boolean isConnectionCloseForced()(Code) | | Tests if the connection should be force-closed when no longer needed.
true if the connection must be closed |
isHttp11 | public boolean isHttp11()(Code) | | Returns true if version 1.1 of the HTTP protocol should be
used per default, false if version 1.0 should be used.
true to use HTTP/1.1, false to use 1.0HttpMethodParams.getVersion |
isRequestSent | public 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 |
isStrictMode | public boolean isStrictMode()(Code) | | org.apache.commons.httpclient.params.HttpParams.setParameter(StringObject) false |
readResponse | protected void readResponse(HttpState state, HttpConnection conn) throws IOException, HttpException(Code) | | Reads the response from the given
HttpConnection connection .
The response is processed as the following sequence of actions:
-
HttpMethodBase.readStatusLine(HttpState,HttpConnection) is
invoked to read the request line.
-
HttpMethodBase.processStatusLine(HttpState,HttpConnection) is invoked, allowing the method to process the status line if
desired.
-
HttpMethodBase.readResponseHeaders(HttpState,HttpConnection) is invoked to read
the associated headers.
-
HttpMethodBase.processResponseHeaders(HttpState,HttpConnection) is invoked, allowing
the method to process the headers if desired.
-
HttpMethodBase.readResponseBody(HttpState,HttpConnection) is
invoked to read the associated body (if any).
-
HttpMethodBase.processResponseBody(HttpState,HttpConnection) is invoked, allowing the
method to process the response body if desired.
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.)
Parameters: state - the HttpState state information associated with this method Parameters: conn - 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. |
readResponseBody | protected void readResponseBody(HttpState state, HttpConnection conn) throws IOException, HttpException(Code) | | Read the response body from the given
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.
Parameters: state - the HttpState state information associated with this method Parameters: conn - 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. See Also: HttpMethodBase.readResponse See Also: HttpMethodBase.processResponseBody |
readResponseHeaders | protected void readResponseHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException(Code) | | Reads the response headers from the given
HttpConnection 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)
Parameters: state - the HttpState state information associated with this method Parameters: conn - 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. See Also: HttpMethodBase.readResponse See Also: HttpMethodBase.processResponseHeaders |
readStatusLine | protected void readStatusLine(HttpState state, HttpConnection conn) throws IOException, HttpException(Code) | | Read the status line from the given
HttpConnection , setting my
HttpMethodBase.getStatusCode status code and
HttpMethodBase.getStatusText statustext .
Subclasses may want to override this method to to customize the
processing.
Parameters: state - the HttpState state information associated with this method Parameters: conn - 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. See Also: StatusLine |
recycle | public 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: HttpMethodBase.releaseConnection() |
releaseConnection | public void releaseConnection()(Code) | | 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.
since: 2.0 |
removeRequestHeader | public void removeRequestHeader(String headerName)(Code) | | Remove the request header associated with the given name. Note that
header-name matching is case insensitive.
Parameters: headerName - the header name |
removeRequestHeader | public void removeRequestHeader(Header header)(Code) | | Removes the given request header.
Parameters: header - the header |
responseBodyConsumed | protected void responseBodyConsumed()(Code) | | A response has been consumed.
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.
|
setConnectionCloseForced | protected void setConnectionCloseForced(boolean b)(Code) | | Sets whether or not the connection should be force-closed when no longer
needed. This value should only be set to true in abnormal
circumstances, such as HTTP protocol violations.
Parameters: b - true if the connection must be closed, false otherwise. |
setDoAuthentication | public 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 challengesauthomatically, false otherwise. since: 2.0 |
setFollowRedirects | public 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. |
setHostConfiguration | public void setHostConfiguration(HostConfiguration hostconfig)(Code) | | Sets the
HostConfiguration host configuration .
Parameters: hostconfig - The hostConfiguration to set |
setHttp11 | public void setHttp11(boolean http11)(Code) | | Sets whether version 1.1 of the HTTP protocol should be used per default.
Parameters: http11 - true to use HTTP/1.1, false to use 1.0HttpMethodParams.setVersion(HttpVersion) |
setMethodRetryHandler | public void setMethodRetryHandler(MethodRetryHandler handler)(Code) | | Sets the
MethodRetryHandler retry handler for this HTTP method
Parameters: handler - the methodRetryHandler to use when this method executedHttpMethodParams |
setParams | public void setParams(HttpMethodParams params)(Code) | | Assigns
HttpMethodParams HTTP protocol parameters for this method.
since: 3.0 See Also: HttpMethodParams |
setPath | public 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 | public void setQueryString(String queryString)(Code) | | Sets the query string of this HTTP method. The caller must ensure that the string
is properly URL encoded. The query string should not start with the question
mark character.
Parameters: queryString - the query string See Also: EncodingUtil.formUrlEncode(NameValuePair[]String) |
setQueryString | public void setQueryString(NameValuePair[] params)(Code) | | 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.
Parameters: params - an array of NameValuePairs to add as query stringparameters. The name/value pairs will be automcatically URL encoded See Also: EncodingUtil.formUrlEncode(NameValuePair[]String) See Also: HttpMethodBase.setQueryString(String) |
setRequestHeader | public void setRequestHeader(String headerName, String headerValue)(Code) | | Set the specified request header, overwriting any previous value. Note
that header-name matching is case-insensitive.
Parameters: headerName - the header's name Parameters: headerValue - the header's value |
setRequestHeader | public void setRequestHeader(Header header)(Code) | | Sets the specified request header, overwriting any previous value.
Note that header-name matching is case insensitive.
Parameters: header - the header |
setResponseStream | protected void setResponseStream(InputStream responseStream)(Code) | | Sets the response stream.
Parameters: responseStream - The new response stream. |
setStrictMode | public void setStrictMode(boolean strictMode)(Code) | | Defines how strictly HttpClient follows the HTTP protocol specification
(RFC 2616 and other relevant RFCs). In the strict mode HttpClient 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) |
setURI | public 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 |
shouldCloseConnection | protected boolean shouldCloseConnection(HttpConnection conn)(Code) | | Tests if the connection should be closed after the method has been executed.
The connection will be left open when using HTTP/1.1 or if Connection:
keep-alive header was sent.
Parameters: conn - the connection in question boolean true if we should close the connection. |
validate | public boolean validate()(Code) | | Returns true the method is ready to execute, false otherwise.
This implementation always returns true. |
writeRequestBody | protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws IOException, HttpException(Code) | | Writes the request body to the given
HttpConnection 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.
Parameters: state - the HttpState state information associated with this method Parameters: conn - the HttpConnection connection used to executethis HTTP method true 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. |
writeRequestLine | protected void writeRequestLine(HttpState state, HttpConnection conn) throws IOException, HttpException(Code) | | Writes the request line to the given
HttpConnection connection .
Subclasses may want to override this method to to customize the
processing.
Parameters: state - the HttpState state information associated with this method Parameters: conn - 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. See Also: HttpMethodBase.generateRequestLine |
|
|