|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.httpclient.HttpMethodBase org.apache.commons.httpclient.methods.ExpectContinueMethod org.apache.commons.httpclient.methods.EntityEnclosingMethod org.apache.commons.httpclient.methods.PostMethod
public class 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 |
---|
effectiveVersion, statusLine |
Constructor Summary | |
---|---|
PostMethod()
No-arg constructor. |
|
PostMethod(String uri)
Constructor specifying a URI. |
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 |
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 |
Methods inherited from class org.apache.commons.httpclient.methods.EntityEnclosingMethod |
---|
addContentLengthRequestHeader, addRequestHeaders, generateRequestBody, getFollowRedirects, getRequestCharSet, getRequestContentLength, getRequestEntity, recycle, setContentChunked, setFollowRedirects, setRequestBody, setRequestBody, setRequestContentLength, setRequestContentLength, setRequestEntity, writeRequestBody |
Methods inherited from class org.apache.commons.httpclient.methods.ExpectContinueMethod |
---|
getUseExpectHeader, setUseExpectHeader |
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 URIMethod Detail |
---|
public String getName()
getName
in interface HttpMethod
getName
in class HttpMethodBase
protected boolean hasRequestContent()
This method must be overwritten by sub-classes that implement alternative request content input methods
hasRequestContent
in class EntityEnclosingMethod
protected void clearRequestBody()
This method must be overwritten by sub-classes that implement alternative request content input methods
clearRequestBody
in class EntityEnclosingMethod
protected RequestEntity generateRequestEntity()
EntityEnclosingMethod.generateRequestBody()
if parameters have not been set.
generateRequestEntity
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 parameter
public 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 nullpublic 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 nullpublic 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 nullpublic void setRequestBody(NameValuePair[] parametersBody) throws IllegalArgumentException
parametersBody
- The array of parameters to add.
IllegalArgumentException
- when param parameters are null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |