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_CHUNKEDeffectiveVersion, statusLine| 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.
|
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
|
addContentLengthRequestHeader, addRequestHeaders, generateRequestBody, getFollowRedirects, getRequestCharSet, getRequestContentLength, getRequestEntity, recycle, setContentChunked, setFollowRedirects, setRequestBody, setRequestBody, setRequestContentLength, setRequestContentLength, setRequestEntity, writeRequestBodygetUseExpectHeader, setUseExpectHeaderabort, addCookieRequestHeader, addHostRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getEffectiveVersion, getHostAuthState, getHostConfiguration, getMethodRetryHandler, getParams, getPath, getProxyAuthenticationRealm, getProxyAuthState, getQueryString, getRecoverableExceptionCount, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getRequestHeaders, getResponseBody, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isAborted, isConnectionCloseForced, isHttp11, isRequestSent, isStrictMode, processCookieHeaders, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseBody, readResponseHeaders, readStatusLine, releaseConnection, removeRequestHeader, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setHostConfiguration, setHttp11, setMethodRetryHandler, setParams, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, setURI, shouldCloseConnection, validate, writeRequest, writeRequestHeaders, writeRequestLinepublic 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 HttpMethodBaseprotected 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 RequestEntity generateRequestEntity()
EntityEnclosingMethod.generateRequestBody() if parameters have not been set.generateRequestEntity in class EntityEnclosingMethodpublic 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 © 2020 Internet2. All rights reserved.