|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.http.HTTPUtils
Provides various HTTP-related utilities.
Can be used instead of the javax.servlet.http.HttpUtils class.
Constructor Summary | |
HTTPUtils()
|
Method Summary | |
static java.lang.String |
encodeTags(java.lang.String s)
Encodes the < and > tags to HTML entities. |
static java.lang.String |
escapeURL(java.lang.String s,
java.lang.String enc)
Escapes the given URL. |
static java.lang.StringBuffer |
getRequestURL(Request request)
Reconstructs the URL from the given request object. |
static void |
parseMultipartData(java.util.Map parameters,
java.util.Map attributes,
int len,
java.io.InputStream in,
java.lang.String contentType)
Parses the data obtained from the multipart POST request body. |
static void |
parsePostData(java.util.Map parameters,
int len,
java.io.InputStream in,
java.lang.String enc)
Parses the data obtained from the POST request. |
static void |
parseQueryString(java.util.Map parameters,
java.lang.String s,
java.lang.String enc)
Parses the query string. |
static java.lang.String |
unescapeURL(java.lang.String s,
java.lang.String enc)
Unescapes the given URL. |
static java.lang.String |
urlDecode(java.lang.String s,
java.lang.String enc)
Decodes a MIME format called x-www-form-urlencoded to string. |
static java.lang.String |
urlEncode(java.lang.String s,
java.lang.String enc)
Encodes a string into a MIME format called x-www-form-urlencoded. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HTTPUtils()
Method Detail |
public static java.lang.StringBuffer getRequestURL(Request request)
The returned URL consists of a protocol, server name, port number and URI path, but it does not include the query string parameters. It is encoded according to the x-www-form-urlencoded format.
request
- the request
public static java.lang.String urlDecode(java.lang.String s, java.lang.String enc) throws java.io.IOException
The decoded ocets are converted to Java string using the given encoding.
s
- the encoded stringenc
- the encoding
java.io.IOException
- if the encoding is not validpublic static java.lang.String unescapeURL(java.lang.String s, java.lang.String enc) throws java.io.IOException
The unescaped octets are converted to characters using the given encoding.
s
- the escaped stringenc
- the encoding
java.io.IOException
- if the encoding is not validpublic static java.lang.String urlEncode(java.lang.String s, java.lang.String enc) throws java.io.IOException
String is converted to octets using the given encoding.
s
- the stringenc
- the encoding
java.io.IOException
- if the encoding is not valid or an error occuredpublic static java.lang.String escapeURL(java.lang.String s, java.lang.String enc) throws java.io.IOException
Characters are converted to octets using the given encoding.
s
- the stringenc
- the encoding
java.io.IOException
- if the encoding is not valid or an error occuredpublic static java.lang.String encodeTags(java.lang.String s)
s
- the input string
public static void parseQueryString(java.util.Map parameters, java.lang.String s, java.lang.String enc) throws java.io.IOException
The parsed parameters will be appended to the given Map. The query string must be in the x-www-form-urlencoded format. The decoded data is converted to string according to the given encoding.
parameters
- the parameterss
- the query stringenc
- the encoding
java.io.IOException
- if the encoding is not validpublic static void parsePostData(java.util.Map parameters, int len, java.io.InputStream in, java.lang.String enc) throws java.io.IOException
The parsed parameters will be appended to the given Map. The decoded parameters are converted to strings according to the given encoding.
parameters
- the parameterslen
- the length of the POST bodyin
- the input streamenc
- the encoding
java.io.IOException
- if an error occured during the parsing
java.io.UnsupportedEncodingException
- if the encoding ist no supportedpublic static void parseMultipartData(java.util.Map parameters, java.util.Map attributes, int len, java.io.InputStream in, java.lang.String contentType) throws java.io.IOException
Multipart data are typically used by HTML forms for file-uploading via the PUT method. The parsed parameters will be appended to the given Map.
parameters
- the parameterslen
- the length of the POST bodyin
- the input streamcontentType
- the content-type of data
java.io.IOException
- if an error occured during the parsing
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |