EAF 7.4 Implementation

com.lutris.http
Class HttpUtils

java.lang.Object
  extended by com.lutris.http.HttpUtils

public class HttpUtils
extends java.lang.Object

Utility methods useful to for HTTP.


Constructor Summary
HttpUtils()
           
 
Method Summary
static java.lang.StringBuffer getRequestURL(com.lutris.appserver.server.httpPresentation.HttpPresentationRequest req)
          Obtains the URL used by the client to make the current request, without the query parameters.
static java.util.Hashtable parsePostData(int len, java.io.InputStream in)
          Parses FORM data posted by a client using the HTTP POST method and the application/x-www-form-urlencoded MIME type.
static java.util.Hashtable parseQueryString(java.lang.String s)
          Decodes a query string in the format specified by the MIME type "application/x-www-form-urlencoded".
static java.lang.String trimQueryString(java.lang.String s)
          Trims the left-hand side of a URL until the character '?' is reached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpUtils

public HttpUtils()
Method Detail

trimQueryString

public static java.lang.String trimQueryString(java.lang.String s)
Trims the left-hand side of a URL until the character '?' is reached. This is useful for raw URLs that need to be parsed as query strings.

Parameters:
s - The string to trim.
Returns:
The trimmed string.

parseQueryString

public static java.util.Hashtable parseQueryString(java.lang.String s)
Decodes a query string in the format specified by the MIME type "application/x-www-form-urlencoded". Such a string consists of encoded key/value pairs in the form key=value. A hash table is returned with each value indexed by its corresponding key. If a key appears once in the query string, then the value will be of type String. If the key appears more than once, then the value will be an array of type String.

Parameters:
s - The string to parse.
Returns:
A Hashtable containing the values indexed by their corresponding keys.

parsePostData

public static java.util.Hashtable parsePostData(int len,
                                                java.io.InputStream in)
                                         throws java.lang.IllegalArgumentException,
                                                java.io.IOException
Parses FORM data posted by a client using the HTTP POST method and the application/x-www-form-urlencoded MIME type.

Parameters:
len - The maximum number of bytes to read from the input stream.
in - The input stream from which to read the form data.
Returns:
A Hashtable containing the values indexed by their corresponding keys.
Throws:
java.lang.IllegalArgumentException - If the query string is not formatted correctly.
java.io.IOException - If an I/O error occurs while reading the input stream.

getRequestURL

public static java.lang.StringBuffer getRequestURL(com.lutris.appserver.server.httpPresentation.HttpPresentationRequest req)
                                            throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Obtains the URL used by the client to make the current request, without the query parameters. Returns a StringBuffer object that can be appended to, if the query string must be appended.

Parameters:
req - presentation request object from which to extract the URL.
Returns:
A string buffer object containing the extracted URL.
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException - If an exception is generated by the req object.

EAF 7.4 Implementation