|
|||||||||
| Home >> All >> com >> mockobjects >> apache >> commons >> [ httpclient overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.mockobjects.apache.commons.httpclient
Class MockHttpMethod

java.lang.Objectcom.mockobjects.MockObject
com.mockobjects.apache.commons.httpclient.MockMethodHelper
com.mockobjects.apache.commons.httpclient.MockHttpMethod
- All Implemented Interfaces:
- org.apache.commons.httpclient.HttpMethod, com.mockobjects.Verifiable
- public class MockHttpMethod
- extends MockMethodHelper
- implements org.apache.commons.httpclient.HttpMethod
- extends MockMethodHelper
| Constructor Summary | |
MockHttpMethod()
|
|
| Method Summary | |
void |
addGetResponseHeader(java.lang.String key,
org.apache.commons.httpclient.Header header)
|
void |
addRequestHeader(org.apache.commons.httpclient.Header header)
Adds the specified request header, not overwriting any previous value. |
void |
addRequestHeader(java.lang.String name,
java.lang.String value)
Adds the specified request header, not overwriting any previous value. |
int |
execute(org.apache.commons.httpclient.HttpState state,
org.apache.commons.httpclient.HttpConnection connection)
Executes this method using the specified HttpConnection and
HttpState. |
boolean |
getFollowRedirects()
Returns true if the HTTP method should automatically follow HTTP redirects (status code 302, etc.), false otherwise. |
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 name)
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 java.lang.String. |
org.apache.commons.httpclient.Header |
getResponseHeader(java.lang.String key)
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. |
java.lang.String |
getStatusText()
Returns the status text (or "reason phrase") associated with the latest response. |
boolean |
hasBeenUsed()
Returns true if the HTTP method has been already executed 55 , but not recycled 55 . |
boolean |
isStrictMode()
Returns the value of the strict mode flag. |
void |
recycle()
Recycles the HTTP method so that it can be used again. |
void |
removeRequestHeader(java.lang.String name)
Removes all request headers with the given name. |
void |
setFollowRedirects(boolean followRedirects)
Sets whether or not the HTTP method should automatically follow HTTP redirects (status code 302, etc.) |
void |
setPath(java.lang.String path)
Sets the path of the HTTP method. |
void |
setQueryString(org.apache.commons.httpclient.NameValuePair[] nameValuePair)
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 name,
java.lang.String value)
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. |
| Methods inherited from class com.mockobjects.MockObject |
assertEquals, assertEquals, assertTrue, fail, notImplemented, notYetImplemented, notYetImplemented, verify |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.commons.httpclient.HttpMethod |
abort, addResponseFooter, getDoAuthentication, getHostAuthState, getHostConfiguration, getParams, getProxyAuthState, getRequestHeaders, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaders, getStatusLine, getURI, isRequestSent, releaseConnection, removeRequestHeader, setDoAuthentication, setParams, setURI |
| Constructor Detail |
MockHttpMethod
public MockHttpMethod()
| Method Detail |
getName
public java.lang.String getName()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Obtains the name of the HTTP method as used in the HTTP request line,
for example "GET" or "POST".
- Specified by:
getNamein interfaceorg.apache.commons.httpclient.HttpMethod
setPath
public void setPath(java.lang.String path)
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Sets the path of the HTTP method.
It is responsibility of the caller to ensure that the path is
properly encoded (URL safe).
- Specified by:
setPathin interfaceorg.apache.commons.httpclient.HttpMethod
getPath
public java.lang.String getPath()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - 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.
- Specified by:
getPathin interfaceorg.apache.commons.httpclient.HttpMethod
setStrictMode
public void setStrictMode(boolean strictMode)
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - 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.
- Specified by:
setStrictModein interfaceorg.apache.commons.httpclient.HttpMethod
isStrictMode
public boolean isStrictMode()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Returns the value of the strict mode flag.
- Specified by:
isStrictModein interfaceorg.apache.commons.httpclient.HttpMethod
setRequestHeader
public void setRequestHeader(java.lang.String name, java.lang.String value)
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Sets the specified request header, overwriting any
previous value.
Note that header-name matching is case insensitive.
- Specified by:
setRequestHeaderin interfaceorg.apache.commons.httpclient.HttpMethod
setRequestHeader
public void setRequestHeader(org.apache.commons.httpclient.Header header)
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Sets the specified request header, overwriting any
previous value.
Note that header-name matching is case insensitive.
- Specified by:
setRequestHeaderin interfaceorg.apache.commons.httpclient.HttpMethod
addRequestHeader
public void addRequestHeader(java.lang.String name, java.lang.String value)
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - 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.
- Specified by:
addRequestHeaderin interfaceorg.apache.commons.httpclient.HttpMethod
addRequestHeader
public void addRequestHeader(org.apache.commons.httpclient.Header header)
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - 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.
- Specified by:
addRequestHeaderin interfaceorg.apache.commons.httpclient.HttpMethod
getRequestHeader
public org.apache.commons.httpclient.Header getRequestHeader(java.lang.String name)
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - 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.
- Specified by:
getRequestHeaderin interfaceorg.apache.commons.httpclient.HttpMethod
removeRequestHeader
public void removeRequestHeader(java.lang.String name)
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Removes all request headers with the given name.
Note that header-name matching is case insensitive.
- Specified by:
removeRequestHeaderin interfaceorg.apache.commons.httpclient.HttpMethod
getFollowRedirects
public boolean getFollowRedirects()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Returns true if the HTTP method should automatically follow HTTP redirects
(status code 302, etc.), false otherwise.
- Specified by:
getFollowRedirectsin interfaceorg.apache.commons.httpclient.HttpMethod
setFollowRedirects
public void setFollowRedirects(boolean followRedirects)
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Sets whether or not the HTTP method should automatically follow HTTP redirects
(status code 302, etc.)
- Specified by:
setFollowRedirectsin interfaceorg.apache.commons.httpclient.HttpMethod
setQueryString
public void setQueryString(java.lang.String queryString)
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - 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.
- Specified by:
setQueryStringin interfaceorg.apache.commons.httpclient.HttpMethod
setQueryString
public void setQueryString(org.apache.commons.httpclient.NameValuePair[] nameValuePair)
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - 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.
- Specified by:
setQueryStringin interfaceorg.apache.commons.httpclient.HttpMethod
getQueryString
public java.lang.String getQueryString()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Returns the query string of this HTTP method.
- Specified by:
getQueryStringin interfaceorg.apache.commons.httpclient.HttpMethod
getRequestHeaders
public org.apache.commons.httpclient.Header[] getRequestHeaders()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - 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.- Specified by:
getRequestHeadersin interfaceorg.apache.commons.httpclient.HttpMethod
validate
public boolean validate()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Returns true the method is ready to execute, false otherwise.
- Specified by:
validatein interfaceorg.apache.commons.httpclient.HttpMethod
getStatusCode
public int getStatusCode()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Returns the status code associated with the latest response.
- Specified by:
getStatusCodein interfaceorg.apache.commons.httpclient.HttpMethod
getStatusText
public java.lang.String getStatusText()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Returns the status text (or "reason phrase") associated with the latest
response.
- Specified by:
getStatusTextin interfaceorg.apache.commons.httpclient.HttpMethod
getResponseHeaders
public org.apache.commons.httpclient.Header[] getResponseHeaders()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Returns the response headers from the most recent execution of this request.
- Specified by:
getResponseHeadersin interfaceorg.apache.commons.httpclient.HttpMethod
getResponseBody
public byte[] getResponseBody()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - 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,
nullis returned. Note that this method does not propagate I/O exceptions. If an error occurs while reading the body,nullwill be returned.- Specified by:
getResponseBodyin interfaceorg.apache.commons.httpclient.HttpMethod
getResponseBodyAsString
public java.lang.String getResponseBodyAsString()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Returns the response body of the HTTP method, if any, as a java.lang.String.
If response body is not available or cannot be read, null is returned.
The raw bytes in the body are converted to a
Stringusing 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,
nullwill be returned.- Specified by:
getResponseBodyAsStringin interfaceorg.apache.commons.httpclient.HttpMethod
getResponseBodyAsStream
public java.io.InputStream getResponseBodyAsStream() throws java.io.IOException
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - 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,
nullis returned. Additionally,nullmay be returned if HttpMethod.releaseConnection()>HttpMethod.releaseConnection()55 has been called or if this method was called previously and the resulting stream was closed.- Specified by:
getResponseBodyAsStreamin interfaceorg.apache.commons.httpclient.HttpMethod
hasBeenUsed
public boolean hasBeenUsed()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Returns true if the HTTP method has been already executed 55 ,
but not recycled 55 .
- Specified by:
hasBeenUsedin interfaceorg.apache.commons.httpclient.HttpMethod
execute
public int execute(org.apache.commons.httpclient.HttpState state, org.apache.commons.httpclient.HttpConnection connection) throws org.apache.commons.httpclient.HttpException, java.io.IOException
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - Executes this method using the specified
HttpConnectionandHttpState.- Specified by:
executein interfaceorg.apache.commons.httpclient.HttpMethod
recycle
public void recycle()
- Description copied from interface:
org.apache.commons.httpclient.HttpMethod - 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.
- Specified by:
recyclein interfaceorg.apache.commons.httpclient.HttpMethod
getResponseHeader
public org.apache.commons.httpclient.Header getResponseHeader(java.lang.String key)
addGetResponseHeader
public void addGetResponseHeader(java.lang.String key, org.apache.commons.httpclient.Header header)
|
|||||||||
| Home >> All >> com >> mockobjects >> apache >> commons >> [ httpclient overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC