|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsunlabs.brazil.util.http.HttpUtil (view source)
public class HttpUtil
The HttpUtil
class contains methods for performing simple
HTTP operations.
Method Summary | |
---|---|
static void |
extractQuery(String query,
Dictionary table)
Turns x-www-form-urlencoded form data into a dictionary. |
static String |
extractUrlHost(String url)
Get the host portion of a Url String. |
static String |
extractUrlPath(String url)
Get the path portion of a Url String. |
static String |
extractUrlPort(String url)
Get the port portion of a Url String as a string. |
static String |
extractUrlProtocol(String url)
Get the protocol portion of a Url String. |
static String |
formatTime()
Returns a string containing the current time as an HTTP-formatted date. |
static String |
formatTime(long time)
Returns a string containing an HTTP-formatted date. |
static String |
getStatusPhrase(int code)
Returns the HTTP error string associated with the integer error code. |
static String |
htmlEncode(String src)
Converts a string into a valid HTML fragment. |
static long |
parseTime(String time)
Convert a last-modified date in "standard" format into a time stamp. |
static String |
urlDecode(String src)
Decodes a URL-encoded string by replacing all the "%XX" escape sequences in the string with the corresponding character. |
static String |
urlEncode(String src)
Maps a string to be used in a query or post into a form that is acceptable in an URL. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static String htmlEncode(String src)
&#xx;
(their "decimal
reference" form).
src
- The string to convert.
public static String urlEncode(String src)
URL strings may not contain non-alphanumeric characters. All non-alphanumeric characters are converted to the escape sequence "%XX", where XX is the hexadecimal value of that character's code.
Note that the space character " " is NOT converted to "+". That is a common misconception. "+" represents a space only in query strings, not in the URL. "%20" is how an actual space character must be passed in an URL, and is also an acceptable way of passing a space in a query string.
src
- The string to convert.
public static String urlDecode(String src)
Malformed "%XX" sequences are silently ignored.
src
- The URL-encoded string.
public static String formatTime()
public static String formatTime(long time)
time
- The date to format (current time in msec).
public static long parseTime(String time)
time
- A correctly formatted HTTP date string.
public static void extractQuery(String query, Dictionary table)
query
- The x-www-form-urlencoded string. May be null
table
- The dictionary to insert the form data into.public static String extractUrlProtocol(String url)
public static String extractUrlHost(String url)
public static String extractUrlPort(String url)
public static String extractUrlPath(String url)
public static String getStatusPhrase(int code)
code
- The code to look up.
|
Version Kenai-svn-r24, Generated 08/18/09 Copyright (c) 2001-2009, Sun Microsystems. |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |