org.mmbase.util
Class HttpPost

java.lang.Object
  extended byorg.mmbase.util.HttpPost

public class HttpPost
extends java.lang.Object

HttpPost handles all the PostInformation

Version:
$Id: HttpPost.java,v 1.26 2003/12/03 12:29:46 keesj Exp $
Author:
Daniel Ockeloen, Rico Jansen, Rob Vermeulen

Field Summary
static java.lang.String CONFIG_FILE
           
static int DEFAULT_MAX_IN_MEMORY_PARAMETER_SIZE
           
static int DEFAULT_MAX_PARAMETER_SIZE
           
static int DEFAULT_MAX_REQUEST_SIZE
           
static java.lang.String MAX_IN_MEMORY_PARAMETER_SIZE_PROPERTY
           
static java.lang.String MAX_PARAMETER_SIZE_PROPERTY
           
static java.lang.String MAX_REQUEST_SIZE_PROPERTY
           
static java.lang.String UPLOAD_DIR_PROPERTY
           
 
Constructor Summary
HttpPost(javax.servlet.http.HttpServletRequest req)
          Initialise WorkerPostHandler
 
Method Summary
 boolean checkPostMultiParameter(java.lang.String name)
          This method checks if the parameter is a multivalued one (as returned by a multiple select form) it returns true if so and false if not.
protected  void finalize()
          Destuctor removes the tmp-files
 java.util.Vector getPostMultiParameter(java.lang.String name)
          This method returns the value of the postparameter as a Vector.
 java.util.Vector getPostMultiParameter(java.lang.String name, java.lang.String encoding)
          This method returns the value of the postparameter as a Vector.
 java.lang.String getPostParameter(java.lang.String name)
          This method returns the value of the postparameter as a String.
 byte[] getPostParameterBytes(java.lang.String name)
          This method returns the value of the postparameter as a String.
 java.lang.String getPostParameterFile(java.lang.String name)
          This method returns the filename containing the postparametervalue If it is a parameter with multiple values it returns the first one.
 java.util.Hashtable getPostParameters()
          This method returns the Hashtable containing the POST information.
 boolean isPostedToFile()
           
 byte[] readContentLength(javax.servlet.http.HttpServletRequest req)
          read a block into a array of ContentLenght size from the users networksocket
 boolean readPostFormData(byte[] postbuffer, java.util.Hashtable post_header, java.lang.String line)
          read post info from buffer, must be defined in multipart/form-data format.
 boolean readPostFormData(java.lang.String formFile, java.util.Hashtable post_header, java.lang.String line)
          read post info from buffer, must be defined in multipart/form-data format.
 void reset()
          resets WorkerPosthandler
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_FILE

public static final java.lang.String CONFIG_FILE
See Also:
Constant Field Values

MAX_REQUEST_SIZE_PROPERTY

public static final java.lang.String MAX_REQUEST_SIZE_PROPERTY
See Also:
Constant Field Values

MAX_IN_MEMORY_PARAMETER_SIZE_PROPERTY

public static final java.lang.String MAX_IN_MEMORY_PARAMETER_SIZE_PROPERTY
See Also:
Constant Field Values

MAX_PARAMETER_SIZE_PROPERTY

public static final java.lang.String MAX_PARAMETER_SIZE_PROPERTY
See Also:
Constant Field Values

UPLOAD_DIR_PROPERTY

public static final java.lang.String UPLOAD_DIR_PROPERTY
See Also:
Constant Field Values

DEFAULT_MAX_REQUEST_SIZE

public static final int DEFAULT_MAX_REQUEST_SIZE
See Also:
Constant Field Values

DEFAULT_MAX_PARAMETER_SIZE

public static final int DEFAULT_MAX_PARAMETER_SIZE
See Also:
Constant Field Values

DEFAULT_MAX_IN_MEMORY_PARAMETER_SIZE

public static final int DEFAULT_MAX_IN_MEMORY_PARAMETER_SIZE
See Also:
Constant Field Values
Constructor Detail

HttpPost

public HttpPost(javax.servlet.http.HttpServletRequest req)
Initialise WorkerPostHandler

Method Detail

finalize

protected void finalize()
Destuctor removes the tmp-files


reset

public void reset()
resets WorkerPosthandler


checkPostMultiParameter

public boolean checkPostMultiParameter(java.lang.String name)
                                throws PostValueToLargeException
This method checks if the parameter is a multivalued one (as returned by a multiple select form) it returns true if so and false if not. It will also return false when the parameter doesn't exist.

Throws:
PostValueToLargeException
See Also:
getPostMultiParameter(java.lang.String), getPostParameter(java.lang.String)

getPostParameters

public java.util.Hashtable getPostParameters()
                                      throws PostValueToLargeException
This method returns the Hashtable containing the POST information. Use of this method is discouraged. Instead use getPostMultiParameter, getPostParameter and checkPostMulitparameter

Throws:
PostValueToLargeException
See Also:
getPostMultiParameter(java.lang.String), getPostParameter(java.lang.String), checkPostMultiParameter(java.lang.String)

getPostParameterBytes

public byte[] getPostParameterBytes(java.lang.String name)
                             throws PostValueToLargeException
This method returns the value of the postparameter as a String. If it is a parameter with multiple values it returns the first one.

Throws:
PostValueToLargeException - will be thrown when the postParameterValue is saved on disk instead of memory.
See Also:
getPostMultiParameter(java.lang.String), checkPostMultiParameter(java.lang.String)

getPostMultiParameter

public java.util.Vector getPostMultiParameter(java.lang.String name)
                                       throws PostValueToLargeException
This method returns the value of the postparameter as a Vector. In case of a parameter with one value, it returns it as a Vector with one element. it also converts the byte[] into strings

Throws:
PostValueToLargeException
See Also:
checkPostMultiParameter(java.lang.String)

getPostMultiParameter

public java.util.Vector getPostMultiParameter(java.lang.String name,
                                              java.lang.String encoding)
                                       throws PostValueToLargeException
This method returns the value of the postparameter as a Vector. In case of a parameter with one value, it returns it as a Vector with one element. it also converts the byte[] into strings

Throws:
PostValueToLargeException
See Also:
checkPostMultiParameter(java.lang.String)

isPostedToFile

public boolean isPostedToFile()
Returns:
true if the post was posted to a file (not in memory)

getPostParameterFile

public java.lang.String getPostParameterFile(java.lang.String name)
                                      throws PostValueToLargeException
This method returns the filename containing the postparametervalue If it is a parameter with multiple values it returns the first one.

Throws:
PostValueToLargeException
See Also:
getPostMultiParameter(java.lang.String), checkPostMultiParameter(java.lang.String)

getPostParameter

public java.lang.String getPostParameter(java.lang.String name)
                                  throws PostValueToLargeException
This method returns the value of the postparameter as a String. If it is a parameter with multiple values it returns the first one.

Throws:
PostValueToLargeException
See Also:
getPostMultiParameter(java.lang.String), checkPostMultiParameter(java.lang.String)

readContentLength

public byte[] readContentLength(javax.servlet.http.HttpServletRequest req)
                         throws PostValueToLargeException
read a block into a array of ContentLenght size from the users networksocket

Returns:
byte[] buffer of length defined in the content-length mimeheader
Throws:
PostValueToLargeException

readPostFormData

public boolean readPostFormData(byte[] postbuffer,
                                java.util.Hashtable post_header,
                                java.lang.String line)
read post info from buffer, must be defined in multipart/form-data format.

Parameters:
postbuffer - buffer with the postbuffer information
post_header - hashtable to put the postbuffer information in

readPostFormData

public boolean readPostFormData(java.lang.String formFile,
                                java.util.Hashtable post_header,
                                java.lang.String line)
read post info from buffer, must be defined in multipart/form-data format. Deze methode gaat in het beginsel alleen werken voor het uploaden van 1 bestand De te vinden markers kunnen anders op de scheiding liggen van 2 blokken Het kan dus voorkomen dat de marker op de scheiding ligt van 2 blokken ook dan zal deze methode falen.

Parameters:
post_header - hashtable to put the fromFile information in


MMBase build 1.7.1.20041002