sunlabs.brazil.util.http
public class HttpUtil extends Object
HttpUtil
class contains methods for performing simple
HTTP operations.
Version: 2.3
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. |
Parameters: query
The x-www-form-urlencoded string. May be null
table
The dictionary to insert the form data into.
Returns: null if the string is an invalid URL.
Returns: null if the string is an invalid URL.
Returns: null if the string is an invalid URL, the empy string if no port was specified.
Returns: null if the string is an invalid URL.
Returns: HTTP date string representing the current time.
Parameters: time The date to format (current time in msec).
Returns: HTTP date string representing the given time.
Parameters: code The code to look up.
Returns: The associated error string.
&#xx;
(their "decimal
reference" form).
Parameters: src The string to convert.
Returns: The string with all the special characters converted to decimal reference form.
Parameters: time A correctly formatted HTTP date string.
Returns: milliseconds since the epoch, or 0 if the conversion failed.
Malformed "%XX" sequences are silently ignored.
Parameters: string The URL-encoded string.
Returns: The decoded version of the given string.
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.
Parameters: string The string to convert.
Returns: The URL-encoded version of the given string.