|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--org.apache.commons.httpclient.HttpMethodBase
|
+--org.apache.commons.httpclient.methods.GetMethod
|
+--org.apache.commons.httpclient.methods.ExpectContinueMethod
|
+--org.apache.commons.httpclient.methods.EntityEnclosingMethod
|
+--org.apache.commons.httpclient.methods.PostMethod
Implements the HTTP POST method.
The HTTP POST method is defined in section 9.5 of RFC2616:
The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions:
- Annotation of existing resources
- Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles
- Providing a block of data, such as the result of submitting a form, to a data-handling process
- Extending a database through an append operation
| Field Summary | |
static String |
FORM_URL_ENCODED_CONTENT_TYPE
The Content-Type for www-form-urlencoded. |
| Fields inherited from class org.apache.commons.httpclient.methods.EntityEnclosingMethod |
CONTENT_LENGTH_AUTO, CONTENT_LENGTH_CHUNKED |
| Fields inherited from class org.apache.commons.httpclient.HttpMethodBase |
USER_AGENT |
| Constructor Summary | |
PostMethod()
No-arg constructor. |
|
PostMethod(String uri)
Constructor specifying a URI. |
|
PostMethod(String uri,
String tempDir)
Deprecated. the client is responsible for disk I/O |
|
PostMethod(String uri,
String tempDir,
String tempFile)
Deprecated. the client is responsible for disk I/O |
|
| Method Summary | |
void |
addParameter(NameValuePair param)
Adds a new parameter to be used in the POST request body. |
void |
addParameter(String paramName,
String paramValue)
Adds a new parameter to be used in the POST request body. |
void |
addParameters(NameValuePair[] parameters)
Adds an array of parameters to be used in the POST request body. |
protected void |
addRequestHeaders(HttpState state,
HttpConnection conn)
Adds Content Type: application/x-www-form-urlencoded header in addition to the "standard" set of headers, if no Content Type header has been set by the user |
protected void |
clearRequestBody()
Clears request body. |
protected byte[] |
generateRequestBody()
Generates the request body. |
String |
getName()
Returns "POST". |
NameValuePair |
getParameter(String paramName)
Gets the parameter of the specified name. |
NameValuePair[] |
getParameters()
Gets the parameters currently added to the PostMethod. |
protected boolean |
hasRequestContent()
Returns true if there is a request body to be sent. |
boolean |
removeParameter(String paramName)
Removes all parameters with the given paramName. |
boolean |
removeParameter(String paramName,
String paramValue)
Removes all parameter with the given paramName and paramValue. |
void |
setParameter(String parameterName,
String parameterValue)
Sets the value of parameter with parameterName to parameterValue. |
void |
setRequestBody(NameValuePair[] parametersBody)
Sets an array of parameters to be used in the POST request body |
| Methods inherited from class org.apache.commons.httpclient.methods.EntityEnclosingMethod |
addContentLengthRequestHeader, getFollowRedirects, getRequestBody, getRequestBodyAsString, getRequestContentLength, recycle, setFollowRedirects, setRequestBody, setRequestBody, setRequestContentLength, writeRequestBody |
| Methods inherited from class org.apache.commons.httpclient.methods.ExpectContinueMethod |
getUseExpectHeader, setUseExpectHeader |
| Methods inherited from class org.apache.commons.httpclient.methods.GetMethod |
getFileData, getTempDir, getTempFile, getUseDisk, readResponseBody, setFileData, setTempDir, setTempFile, setUseDisk |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String FORM_URL_ENCODED_CONTENT_TYPE
| Constructor Detail |
public PostMethod()
public PostMethod(String uri)
uri - either an absolute or relative URI
public PostMethod(String uri,
String tempDir)
uri - either an absolute or relative URItempDir - directory to store temp files in
public PostMethod(String uri,
String tempDir,
String tempFile)
uri - either an absolute or relative URItempDir - directory to store temp files intempFile - file to store temporary data in| Method Detail |
public String getName()
getName in class GetMethodprotected boolean hasRequestContent()
This method must be overwritten by sub-classes that implement alternative request content input methods
hasRequestContent in class EntityEnclosingMethodprotected void clearRequestBody()
This method must be overwritten by sub-classes that implement alternative request content input methods
clearRequestBody in class EntityEnclosingMethodprotected byte[] generateRequestBody()
This method must be overwritten by sub-classes that implement alternative request content input methods
generateRequestBody in class EntityEnclosingMethod
public void setParameter(String parameterName,
String parameterValue)
parameterName - name of the parameterparameterValue - value of the parameterpublic NameValuePair getParameter(String paramName)
paramName - name of the parameterpublic NameValuePair[] getParameters()
public void addParameter(String paramName,
String paramValue)
throws IllegalArgumentException
paramName - The parameter name to add.paramValue - The parameter value to add.IllegalArgumentException - if either argument is null
public void addParameter(NameValuePair param)
throws IllegalArgumentException
param - The parameter to add.IllegalArgumentException - if the argument is null or contains
null valuespublic void addParameters(NameValuePair[] parameters)
parameters - The array of parameters to add.
public boolean removeParameter(String paramName)
throws IllegalArgumentException
paramName - The parameter name to remove.IllegalArgumentException - When the parameter name passed is null
public boolean removeParameter(String paramName,
String paramValue)
throws IllegalArgumentException
paramName - The parameter name to remove.paramValue - The parameter value to remove.IllegalArgumentException - when param name or value are null
public void setRequestBody(NameValuePair[] parametersBody)
throws IllegalArgumentException
parametersBody - The array of parameters to add.IllegalArgumentException - when param parameters are null
protected void addRequestHeaders(HttpState state,
HttpConnection conn)
throws IOException,
HttpException
addRequestHeaders in class ExpectContinueMethodstate - the state information associated with this methodconn - the connection used to execute
this HTTP methodIOException - if an I/O (transport) error occursHttpException - if a protocol exception occurs.HttpRecoverableException - if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP method
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||