org.mmbase.util
Class HttpPost

java.lang.Object
  extended by org.mmbase.util.HttpPost

public class HttpPost
extends Object

HttpPost handles all the PostInformation

Version:
$Id: HttpPost.java 35335 2009-05-21 08:14:41Z michiel $
Author:
Daniel Ockeloen, Rico Jansen, Rob Vermeulen
Application:
SCAN. To port this, use of HttpPost by i.e. taglibs should be replaced with the jakarta FileUpload code.

Field Summary
static String CONFIG_FILE
           
static int DEFAULT_MAX_IN_MEMORY_PARAMETER_SIZE
           
static int DEFAULT_MAX_PARAMETER_SIZE
           
static int DEFAULT_MAX_REQUEST_SIZE
           
static String MAX_IN_MEMORY_PARAMETER_SIZE_PROPERTY
           
static String MAX_PARAMETER_SIZE_PROPERTY
           
static String MAX_REQUEST_SIZE_PROPERTY
           
(package private)  int maxLoop
           
static String UPLOAD_DIR_PROPERTY
           
 
Constructor Summary
HttpPost(HttpServletRequest req)
          Initialise WorkerPostHandler
 
Method Summary
 boolean checkPostMultiParameter(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
 Vector<Object> getPostMultiParameter(String name)
          This method returns the value of the postparameter as a Vector.
 Vector<Object> getPostMultiParameter(String name, String encoding)
          This method returns the value of the postparameter as a Vector.
 String getPostParameter(String name)
          This method returns the value of the postparameter as a String.
 byte[] getPostParameterBytes(String name)
          This method returns the value of the postparameter as a String.
 String getPostParameterFile(String name)
          This method returns the filename containing the postparametervalue If it is a parameter with multiple values it returns the first one.
 Hashtable<String,Object> getPostParameters()
          This method returns the Hashtable containing the POST information.
 boolean isPostedToFile()
           
 byte[] readContentLength(HttpServletRequest req)
          read a block into a array of ContentLenght size from the users networksocket
 boolean readPostFormData(byte[] postbuffer, Hashtable<String,Object> post_header, String line)
          read post info from buffer, must be defined in multipart/form-data format.
 boolean readPostFormData(String formFile, Hashtable<String,Object> post_header, 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 String CONFIG_FILE
See Also:
Constant Field Values

MAX_REQUEST_SIZE_PROPERTY

public static final String MAX_REQUEST_SIZE_PROPERTY
See Also:
Constant Field Values

MAX_IN_MEMORY_PARAMETER_SIZE_PROPERTY

public static final String MAX_IN_MEMORY_PARAMETER_SIZE_PROPERTY
See Also:
Constant Field Values

MAX_PARAMETER_SIZE_PROPERTY

public static final String MAX_PARAMETER_SIZE_PROPERTY
See Also:
Constant Field Values

UPLOAD_DIR_PROPERTY

public static final 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

maxLoop

int maxLoop
Constructor Detail

HttpPost

public HttpPost(HttpServletRequest req)
Initialise WorkerPostHandler

Method Detail

finalize

protected void finalize()
Destuctor removes the tmp-files

Overrides:
finalize in class Object

reset

public void reset()
resets WorkerPosthandler


checkPostMultiParameter

public boolean checkPostMultiParameter(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 Hashtable<String,Object> 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(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 Vector<Object> getPostMultiParameter(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 Vector<Object> getPostMultiParameter(String name,
                                            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)
Since:
MMBase-1.7

getPostParameterFile

public String getPostParameterFile(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 String getPostParameter(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(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,
                                Hashtable<String,Object> post_header,
                                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(String formFile,
                                Hashtable<String,Object> post_header,
                                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:
formFile - buffer with the postbuffer information
post_header - hashtable to put the fromFile information in


MMBase 2.0-SNAPSHOT - null