|
||||||||||
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 specification.
The HTTP POST method is defined in section 8.3 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 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(String uri)
Constructor specifying a URI. |
|
PostMethod(String uri,
String tempDir)
Deprecated. the client is responsible for disk I/O |
|
PostMethod(String uri,
String tempDir,
String tempFile)
Deprecated. the client is responsible for disk I/O |
Method Summary | |
void |
addParameter(NameValuePair param)
Add a new parameter to be used in the POST request body. |
void |
addParameter(String paramName,
String paramValue)
Add a new parameter to be used in the POST request body. |
void |
addParameters(NameValuePair[] parameters)
Add an Array of parameters to be used in the POST request body. |
protected void |
addRequestHeaders(HttpState state,
HttpConnection conn)
Override method of HttpMethodBase
to also add Content-Type header when appropriate. |
protected void |
clearRequestBody()
Clears request body. |
protected byte[] |
generateRequestBody()
Generates 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. |
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)
Set the value of parameter with parameterName to parameterValue. |
void |
setRequestBody(NameValuePair[] parametersBody)
Set 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 String FORM_URL_ENCODED_CONTENT_TYPE
Constructor Detail |
public PostMethod()
public PostMethod(String uri)
uri
- either an absolute or relative URIpublic PostMethod(String uri, String tempDir)
uri
- either an absolute or relative URItempDir
- directory to store temp files inpublic PostMethod(String uri, String tempDir, String tempFile)
uri
- either an absolute or relative URItempDir
- directory to store temp files intempFile
- file to store temporary data inMethod Detail |
public 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(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.public void addParameter(NameValuePair param) throws IllegalArgumentException
param
- The parameter to add.public void addParameters(NameValuePair[] parameters)
parameters
- The array of parameters to add.public boolean removeParameter(String paramName) throws IllegalArgumentException
paramName
- The parameter name to remove.public boolean removeParameter(String paramName, String paramValue) throws IllegalArgumentException
paramName
- The parameter name to remove.paramValue
- The parameter value to remove.public void setRequestBody(NameValuePair[] parametersBody) throws IllegalArgumentException
parametersBody
- The array of parameters to add.protected void addRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException
HttpMethodBase
to also add Content-Type header when appropriate.state
- the client stateconn
- the HttpConnection
the headers will eventually be
written to
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |