org.experlog.lite
Class MultipartRequest

java.lang.Object
  extended by org.experlog.lite.MultipartRequest

public class MultipartRequest
extends java.lang.Object

Extracts parameter values from "multipart; form-data" contained in incoming HTTP servlet requests. For further details concerning multipart requests see RFC 1867.


Field Summary
static java.lang.String fDoubleDash
          Terminating sequence at end of multipart section
static java.lang.String fEmptyLine
          Sequence containing two end of line sequences in multipart data sections thus creating an empty line.
static java.lang.String fEOLN
          End of line sequence in multipart data sections
 
Constructor Summary
MultipartRequest(javax.servlet.http.HttpServletRequest request)
          A convenience constructor allowing size of multipart content of incoming request to be of maximum size.
MultipartRequest(javax.servlet.http.HttpServletRequest request, int maxSize)
          Creates new IncomingMultiPartHttpServlet out of .
 
Method Summary
 java.lang.String getBoundary()
          Extracts boundary from ContentType.
 byte[] getByteContent()
          Getter method to access #mDataBytes.
 int getContentLength()
          Extracts ContentLength from #mRequest.
 java.lang.String getContentType()
          Extracts ContentType from #mRequest.
 javax.servlet.ServletInputStream getDataInputStream()
          Extracts DataInputStream from #mRequest.
 java.lang.String getFileContentType(java.lang.String name)
          Extracts content-type from parameter block with the name specified if available.
 java.lang.String getFileName(java.lang.String name)
          Extracts file name from parameter block with the name specified if available.
 byte[] getFileValue(java.lang.String name)
          Extracts the binary content of parameter if available.
 java.lang.String getHeaderParameter(java.lang.String name)
          To be consistent the name of this method should actually be getParameter.
 java.lang.String getMultipartHeader(java.lang.String name)
          Returns a string containing value of the specified parameter, or null if parameter does not exist.
 java.lang.String getMultipartValue(java.lang.String name)
          Returns a string containing value of the specified parameter, or null if parameter does not exist.
 java.lang.String getParameter(java.lang.String name)
          To be consistent the name of this method should actually be getParameter.
 java.lang.String getQueryString()
          Gets any query string that is part of the HTTP request URI (behind the '?').
 java.lang.String getRemoteAddr()
          Get IP address of calling client host from embedded HttpServletRequest.
 java.lang.String getRequestURL()
          Retrieves URL used to contact server
 java.lang.String getScheme()
          Retrieves scheme used to make request, such as ftp, http, https
 java.lang.String getServerName()
          Retrieves name of server from incoming HttpServletRequest
 int getServerPort()
          Retrieves port id of server from incoming HttpServletRequest
 java.lang.String getShortFileName(java.lang.String name)
          Retrieves the file name contained in the DataBlock with the specified name stripped of any references to its path.
 boolean isSecure()
          Determines whether request was made using a safe channel or not.
static java.lang.String newString(byte[] bytes)
          Creates a new String out of an array of bytes or out of null
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fEOLN

public static final java.lang.String fEOLN
End of line sequence in multipart data sections

See Also:
Constant Field Values

fEmptyLine

public static final java.lang.String fEmptyLine
Sequence containing two end of line sequences in multipart data sections thus creating an empty line.

See Also:
Constant Field Values

fDoubleDash

public static final java.lang.String fDoubleDash
Terminating sequence at end of multipart section

See Also:
Constant Field Values
Constructor Detail

MultipartRequest

public MultipartRequest(javax.servlet.http.HttpServletRequest request)
                 throws javax.servlet.ServletException
A convenience constructor allowing size of multipart content of incoming request to be of maximum size.

Parameters:
request - HttpServletRequest containing multipart message
Throws:
javax.servlet.ServletException - is thrown if thrown by this(request, -1);

MultipartRequest

public MultipartRequest(javax.servlet.http.HttpServletRequest request,
                        int maxSize)
                 throws javax.servlet.ServletException
Creates new IncomingMultiPartHttpServlet out of .

Parameters:
request - HttpServletRequest containing multipart message
maxSize - max. allowable size of multipart message. If smaller than 0 it is assumed to be Integer.MAX_VALUE
Throws:
javax.servlet.ServletException - is thrown if either of the following occurs:
  • incoming request does not have a multipart message
  • multipart message is too large too process
  • IOException occurs while reading multipart message
See Also:
MultipartRequest(HttpServletRequest, int)
Method Detail

newString

public static final java.lang.String newString(byte[] bytes)
Creates a new String out of an array of bytes or out of null

Parameters:
bytes - an array of bytes or null
Returns:
an empty string if bytes is null otherwise a new String out of bytes

getDataInputStream

public javax.servlet.ServletInputStream getDataInputStream()
                                                    throws java.io.IOException
Extracts DataInputStream from #mRequest.

Returns:
DataInputStream associtated with #mRequest
Throws:
java.io.IOException

getContentLength

public int getContentLength()
Extracts ContentLength from #mRequest.

Returns:
ContentLength associtated with #mRequest.

getContentType

public java.lang.String getContentType()
Extracts ContentType from #mRequest.

Returns:
ContentType associtated with #mRequest.

getByteContent

public byte[] getByteContent()
Getter method to access #mDataBytes.

Returns:
mDataBytes Array of bytes containing byte content of original request.

getBoundary

public java.lang.String getBoundary()
Extracts boundary from ContentType.

Returns:
ContentType associtated with #mRequest.

getQueryString

public java.lang.String getQueryString()
Gets any query string that is part of the HTTP request URI (behind the '?'). Same as the CGI variable QUERY_STRING.

Returns:
query string that is part of this request's URI, or null if it contains no query string

getRemoteAddr

public java.lang.String getRemoteAddr()
Get IP address of calling client host from embedded HttpServletRequest.

Returns:
String with IP address of calling client host.

getHeaderParameter

public java.lang.String getHeaderParameter(java.lang.String name)
To be consistent the name of this method should actually be getParameter. However, getParameter will be used to access the parameters included in the multipart body. The same applies to the other methods for accessing parameter names and values. Methods for accessing the HttpServletRequest parameters include the word "Header".

Parameters:
name - String containing name of requested parameter value
Returns:
String containing header parameter value

getMultipartHeader

public java.lang.String getMultipartHeader(java.lang.String name)
Returns a string containing value of the specified parameter, or null if parameter does not exist.

Parameters:
name - String containing the name of the requested parameter value.
Returns:
String or null

getMultipartValue

public java.lang.String getMultipartValue(java.lang.String name)
Returns a string containing value of the specified parameter, or null if parameter does not exist.

Parameters:
name - String containing the name of the requested parameter value.
Returns:
String or null

getFileValue

public byte[] getFileValue(java.lang.String name)
Extracts the binary content of parameter if available.

Parameters:
name - String containing name of parameter of which binary content is requested
Returns:
String Containing substring of mDataString with requested binary content

getFileContentType

public java.lang.String getFileContentType(java.lang.String name)
Extracts content-type from parameter block with the name specified if available.

Parameters:
name - String containing name of parameter of which content-type is requested
Returns:
String Containing requested content-type if name belongs to a file data block otherwise null

getFileName

public java.lang.String getFileName(java.lang.String name)
Extracts file name from parameter block with the name specified if available.

Parameters:
name - String containing name of parameter of which file name is requested
Returns:
String Containing requested file name if name belongs to a file data block otherwise null

getShortFileName

public java.lang.String getShortFileName(java.lang.String name)
Retrieves the file name contained in the DataBlock with the specified name stripped of any references to its path.

Parameters:
name - String containing name of data block of which file name is requested.
Returns:
String containing file name extracted from DataBlock with given name

getParameter

public java.lang.String getParameter(java.lang.String name)
To be consistent the name of this method should actually be getParameter. However, as the depatcher uses the getParameter method to access the object path. The object path parameter, however, is included in the multipart body of mRequest and is not really a HttpServletRequest. Thus getParameter will be used to access the parameters included in the multipart body. The same applies to the other methods for accessing parameter names and values. Methods for accessing the HttpServletRequest parameters include the word "Header".

Parameters:
name - String containing name of requested parameter value
Returns:
String containing header parameter value
See Also:
getHeaderParameter(java.lang.String)

getRequestURL

public java.lang.String getRequestURL()
Retrieves URL used to contact server

Returns:
String with URL used to send request

getScheme

public java.lang.String getScheme()
Retrieves scheme used to make request, such as ftp, http, https

Returns:
String with scheme used to make request.

isSecure

public boolean isSecure()
Determines whether request was made using a safe channel or not.

Returns:
true if channel was safe (eg https) otherwise false

getServerName

public java.lang.String getServerName()
Retrieves name of server from incoming HttpServletRequest

Returns:
String with name of server

getServerPort

public int getServerPort()
Retrieves port id of server from incoming HttpServletRequest

Returns:
int with port id of server