org.apache.commons.httpclient.methods
public class PostMethod extends EntityEnclosingMethod
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
Since: 1.0
Version: $Revision: 155418 $
Field Summary | |
---|---|
static String | FORM_URL_ENCODED_CONTENT_TYPE The Content-Type for www-form-urlencoded. |
Constructor Summary | |
---|---|
PostMethod()
No-arg constructor.
| |
PostMethod(String uri)
Constructor specifying a URI.
|
Method Summary | |
---|---|
void | addParameter(String paramName, String paramValue)
Adds a new parameter to be used in the POST request body.
|
void | addParameter(NameValuePair param)
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 | clearRequestBody()
Clears request body.
|
protected RequestEntity | generateRequestEntity()
Generates a request entity from the post parameters, if present. |
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
|
Since: 1.0
Parameters: uri either an absolute or relative URI
Since: 1.0
Parameters: paramName The parameter name to add. paramValue The parameter value to add.
Throws: IllegalArgumentException if either argument is null
Since: 1.0
Parameters: param The parameter to add.
Throws: IllegalArgumentException if the argument is null or contains null values
Since: 2.0
Parameters: parameters The array of parameters to add.
Since: 2.0
This method must be overwritten by sub-classes that implement alternative request content input methods
Since: 2.0beta1
Since: 3.0
Returns: "POST"
Since: 2.0
Parameters: paramName name of the parameter
Returns: If a parameter exists with the name argument, the coresponding NameValuePair is returned. Otherwise null.
Since: 2.0
Returns: An array of the current parameters
Since: 2.0
This method must be overwritten by sub-classes that implement alternative request content input methods
Returns: boolean
Since: 2.0beta1
Parameters: paramName The parameter name to remove.
Returns: true if at least one parameter was removed
Throws: IllegalArgumentException When the parameter name passed is null
Since: 2.0
Parameters: paramName The parameter name to remove. paramValue The parameter value to remove.
Returns: true if a parameter was removed.
Throws: IllegalArgumentException when param name or value are null
Since: 2.0
Parameters: parameterName name of the parameter parameterValue value of the parameter
Since: 2.0
Parameters: parametersBody The array of parameters to add.
Throws: IllegalArgumentException when param parameters are null
Since: 2.0beta1