org.apache.commons.httpclient.methods
Class PostMethod

java.lang.Object
  |
  +--org.apache.commons.httpclient.HttpMethodBase
        |
        +--org.apache.commons.httpclient.methods.GetMethod
              |
              +--org.apache.commons.httpclient.methods.PostMethod
All Implemented Interfaces:
HttpMethod

public class PostMethod
extends GetMethod

POST Method.

Author:
Remy Maucherat, Doug Sale

Fields inherited from class org.apache.commons.httpclient.methods.GetMethod
fileData, memoryData, tempDir, tempFile, useDisk
 
Fields inherited from class org.apache.commons.httpclient.HttpMethodBase
USER_AGENT
 
Constructor Summary
PostMethod()
          No-arg constructor.
PostMethod(java.lang.String path)
          Path-setting constructor.
PostMethod(java.lang.String path, java.lang.String tempDir)
          Constructor.
PostMethod(java.lang.String path, java.lang.String tempDir, java.lang.String tempFile)
          Constructor.
 
Method Summary
 void addParameter(java.lang.String parameterName, java.lang.String parameterValue)
          Override method of HttpMethodBase to throw IllegalStateException if my request body has already been generated.
protected  void addRequestHeaders(HttpState state, HttpConnection conn)
          Override method of HttpMethodBase to also add Content-Type header when appropriate.
protected  java.lang.String generateRequestBody(java.util.HashMap params)
           
 java.lang.String getName()
          Returns "POST".
protected  int getRequestContentLength()
          Override method of HttpMethodBase to return the length of the request body.
 void recycle()
          Override method of HttpMethodBase to clear my request body.
 void removeParameter(java.lang.String paramName)
          Override method of HttpMethodBase to throw IllegalStateException if my request body has already been generated.
 void removeParameter(java.lang.String paramName, java.lang.String paramValue)
          Override method of HttpMethodBase to throw IllegalStateException if my request body has already been generated.
 void setParameter(java.lang.String parameterName, java.lang.String parameterValue)
          Override method of HttpMethodBase to throw IllegalStateException if my request body has already been generated.
protected  boolean writeRequestBody(HttpState state, HttpConnection conn)
          Override method of HttpMethodBase to write request parameters as the request body.
 
Methods inherited from class org.apache.commons.httpclient.methods.GetMethod
getFileData, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getTempDir, getTempFile, getUseDisk, readResponseBody, setFileData, setTempDir, setTempFile, setUseDisk
 
Methods inherited from class org.apache.commons.httpclient.HttpMethodBase
addAuthorizationRequestHeader, addContentLengthRequestHeader, addCookieRequestHeader, addHostRequestHeader, addRequestHeader, addRequestHeader, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, followRedirects, generateRequestLine, getPath, getQueryString, getRequestHeader, getRequestHeaders, getResponseHeader, getResponseHeaders, getStatusCode, getStatusText, hasBeenUsed, isHttp11, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseHeaders, readStatusLine, removeRequestHeader, setFollowRedirects, setHttp11, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, validate, writeRequest, writeRequestHeaders, writeRequestLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PostMethod

public PostMethod()
No-arg constructor.

PostMethod

public PostMethod(java.lang.String path)
Path-setting constructor.
Parameters:
path - the path to request

PostMethod

public PostMethod(java.lang.String path,
                  java.lang.String tempDir)
Constructor.
Parameters:
path - the path to request
tempDir - directory to store temp files in

PostMethod

public PostMethod(java.lang.String path,
                  java.lang.String tempDir,
                  java.lang.String tempFile)
Constructor.
Parameters:
path - the path to request
tempDir - directory to store temp files in
tempFile - file to store temporary data in
Method Detail

getName

public java.lang.String getName()
Returns "POST".
Overrides:
getName in class GetMethod
Returns:
"POST"

recycle

public void recycle()
Override method of HttpMethodBase to clear my request body.
Overrides:
recycle in class GetMethod

setParameter

public void setParameter(java.lang.String parameterName,
                         java.lang.String parameterValue)
Override method of HttpMethodBase to throw IllegalStateException if my request body has already been generated.
Throws:
java.lang.IllegalStateException - if my request body has already been generated.

addParameter

public void addParameter(java.lang.String parameterName,
                         java.lang.String parameterValue)
Override method of HttpMethodBase to throw IllegalStateException if my request body has already been generated.
Throws:
java.lang.IllegalStateException - if my request body has already been generated.

removeParameter

public void removeParameter(java.lang.String paramName)
Override method of HttpMethodBase to throw IllegalStateException if my request body has already been generated.
Throws:
java.lang.IllegalStateException - if my request body has already been generated.

removeParameter

public void removeParameter(java.lang.String paramName,
                            java.lang.String paramValue)
Override method of HttpMethodBase to throw IllegalStateException if my request body has already been generated.
Throws:
java.lang.IllegalStateException - if my request body has already been generated.

addRequestHeaders

protected void addRequestHeaders(HttpState state,
                                 HttpConnection conn)
                          throws java.io.IOException,
                                 HttpException
Override method of HttpMethodBase to also add Content-Type header when appropriate.
Overrides:
addRequestHeaders in class HttpMethodBase
Following copied from class: org.apache.commons.httpclient.HttpMethodBase
Parameters:
state - the client state
conn - the HttpConnection the headers will eventually be written to
See Also:
HttpMethodBase.writeRequestHeaders(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)

writeRequestBody

protected boolean writeRequestBody(HttpState state,
                                   HttpConnection conn)
                            throws java.io.IOException,
                                   HttpException
Override method of HttpMethodBase to write request parameters as the request body.
Overrides:
writeRequestBody in class HttpMethodBase
Following copied from class: org.apache.commons.httpclient.HttpMethodBase
Returns:
true

getRequestContentLength

protected int getRequestContentLength()
Override method of HttpMethodBase to return the length of the request body. Once this method has been invoked, the request parameters cannot be altered until I am recycled.
Overrides:
getRequestContentLength in class HttpMethodBase
Following copied from class: org.apache.commons.httpclient.HttpMethodBase
Returns:
0, indicating that the request has no body.

generateRequestBody

protected java.lang.String generateRequestBody(java.util.HashMap params)


Copyright (c) 2001 - Apache Software Foundation