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
| Modifier and Type | Field and Description |
|---|---|
static String |
FORM_URL_ENCODED_CONTENT_TYPE
The Content-Type for www-form-urlencoded.
|
CONTENT_LENGTH_AUTO, CONTENT_LENGTH_CHUNKED| Constructor and Description |
|---|
PostMethod()
No-arg constructor.
|
PostMethod(String uri)
Constructor specifying a URI.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
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.
|
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
|
getFollowRedirects, getRequestCharSet, getRequestEntity, recycle, setContentChunked, setFollowRedirects, setRequestBody, setRequestBody, setRequestContentLength, setRequestContentLength, setRequestEntitygetUseExpectHeader, setUseExpectHeaderabort, addRequestHeader, addRequestHeader, addResponseFooter, execute, getAuthenticationRealm, getDoAuthentication, getEffectiveVersion, getHostAuthState, getHostConfiguration, getMethodRetryHandler, getParams, getPath, getProxyAuthenticationRealm, getProxyAuthState, getQueryString, getRecoverableExceptionCount, getRequestHeader, getRequestHeaders, getRequestHeaders, getResponseBody, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaders, getResponseHeaders, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isAborted, isHttp11, isRequestSent, isStrictMode, releaseConnection, removeRequestHeader, removeRequestHeader, setDoAuthentication, setHostConfiguration, setHttp11, setMethodRetryHandler, setParams, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setStrictMode, setURI, validatepublic static final String FORM_URL_ENCODED_CONTENT_TYPE
public PostMethod()
public PostMethod(String uri)
uri - either an absolute or relative URIpublic String getName()
getName in interface HttpMethodgetName in class HttpMethodBasepublic 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 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 nullCopyright © 2010 - 2020 Adobe. All Rights Reserved