|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.enterprise.adaptor.HttpExchanges
public final class HttpExchanges
Utility class for working with HttpExchange
s.
Method Summary | |
---|---|
static void |
enableCompressionIfSupported(HttpExchange ex)
If the client supports it, set the correct headers and streams to provide GZIPed response data to the client. |
static Date |
getIfModifiedSince(HttpExchange ex)
Retrieves and parses the If-Modified-Since from the request, returning null if there was no such header or there was an error. |
static URI |
getRequestUri(HttpExchange ex)
Best-effort attempt to reform the identical URI the client used to contact the server. |
static boolean |
headersSent(HttpExchange ex)
Determines if the headers have already been sent for the exchange. |
static Map<String,List<String>> |
parseQueryParameters(HttpExchange ex,
Charset charset)
Parse request GET query parameters of ex into its parts, correctly
taking into account charset . |
static void |
sendRedirect(HttpExchange ex,
URI location)
Redirect client to location . |
static void |
setLastModified(HttpExchange ex,
Date lastModified)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static URI getRequestUri(HttpExchange ex)
public static void sendRedirect(HttpExchange ex, URI location) throws IOException
location
. The client should retrieve the
referred location via GET, independent of the method of this request.
IOException
public static void enableCompressionIfSupported(HttpExchange ex) throws IOException
responseLength
of 0
when calling HttpExchange.sendResponseHeaders(int, long)
. The exception is when responding to a
HEAD request, in which -1
is required.
IOException
public static Date getIfModifiedSince(HttpExchange ex)
public static boolean headersSent(HttpExchange ex)
This implementation currently uses an imperfect heuristic, but should
work well in most cases. It checks to see if the Date header is present,
which is added during HttpExchange.sendResponseHeaders(int, long)
.
public static void setLastModified(HttpExchange ex, Date lastModified)
public static Map<String,List<String>> parseQueryParameters(HttpExchange ex, Charset charset)
ex
into its parts, correctly
taking into account charset
. The encoding of the GET parameters is
not specified in the request parameters, so it must be negotiated elsewhere
(i.e., via hard-coding). ISO 8859-1 (Latin-1) and UTF-8 are the only
commonly used encodings for query parameters.
ex
- exchange whose request query string is to be parsedcharset
- character set used during encoding
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |