|
||||||||
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 RFC1945:
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 java.lang.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(java.lang.String uri)
Constructor specifying a URI. |
|
PostMethod(java.lang.String uri,
java.lang.String tempDir)
Deprecated. the client is responsible for disk I/O |
|
PostMethod(java.lang.String uri,
java.lang.String tempDir,
java.lang.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(java.lang.String paramName,
java.lang.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. |
java.lang.String |
getName()
Returns "POST". |
NameValuePair |
getParameter(java.lang.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(java.lang.String paramName)
Removes all parameters with the given paramName. |
boolean |
removeParameter(java.lang.String paramName,
java.lang.String paramValue)
Removes all parameter with the given paramName and paramValue. |
void |
setParameter(java.lang.String parameterName,
java.lang.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 java.lang.String FORM_URL_ENCODED_CONTENT_TYPE
Constructor Detail |
public PostMethod()
public PostMethod(java.lang.String uri)
uri
- either an absolute or relative URIpublic PostMethod(java.lang.String uri, java.lang.String tempDir)
uri
- either an absolute or relative URItempDir
- directory to store temp files inpublic PostMethod(java.lang.String uri, java.lang.String tempDir, java.lang.String tempFile)
uri
- either an absolute or relative URItempDir
- directory to store temp files intempFile
- file to store temporary data inMethod Detail |
public java.lang.String getName()
protected boolean hasRequestContent()
This method must be overwritten by sub-classes that implement alternative request content input methods
protected void clearRequestBody()
This method must be overwritten by sub-classes that implement alternative request content input methods
protected byte[] generateRequestBody()
This method must be overwritten by sub-classes that implement alternative request content input methods
public void setParameter(java.lang.String parameterName, java.lang.String parameterValue)
parameterName
- name of the parameterparameterValue
- value of the parameterpublic NameValuePair getParameter(java.lang.String paramName)
paramName
- name of the parameterpublic NameValuePair[] getParameters()
public void addParameter(java.lang.String paramName, java.lang.String paramValue) throws java.lang.IllegalArgumentException
paramName
- The parameter name to add.paramValue
- The parameter value to add.public void addParameter(NameValuePair param) throws java.lang.IllegalArgumentException
param
- The parameter to add.public void addParameters(NameValuePair[] parameters)
parameters
- The array of parameters to add.public boolean removeParameter(java.lang.String paramName) throws java.lang.IllegalArgumentException
paramName
- The parameter name to remove.public boolean removeParameter(java.lang.String paramName, java.lang.String paramValue) throws java.lang.IllegalArgumentException
paramName
- The parameter name to remove.paramValue
- The parameter value to remove.public void setRequestBody(NameValuePair[] parametersBody) throws java.lang.IllegalArgumentException
parametersBody
- The array of parameters to add.protected void addRequestHeaders(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
state
- the state
information associated with this methodconn
- the connection
used to execute
this HTTP method
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |