public static class KawaHttpHandler.Context extends HttpRequestContext
HTTP_NOT_FOUND, HTTP_OK, importServletDefinitions, instance, statusCode, statusReasonPhrase| Constructor and Description |
|---|
Context() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
getAttribute(java.lang.String name)
Get attribute from the server context.
|
java.lang.String |
getContextPath()
Returns the context path, relative to the server root.
|
java.net.InetAddress |
getLocalHost() |
int |
getLocalPort() |
java.net.InetSocketAddress |
getLocalSocketAddress() |
java.lang.String |
getPathTranslated() |
java.lang.String |
getQueryString() |
java.net.InetAddress |
getRemoteHost() |
java.lang.String |
getRemoteIPAddress() |
int |
getRemotePort() |
java.net.InetSocketAddress |
getRemoteSocketAddress() |
java.lang.String |
getRequestHeader(java.lang.String name) |
com.sun.net.httpserver.Headers |
getRequestHeaders() |
java.util.List<java.lang.String> |
getRequestHeaders(java.lang.String name) |
java.lang.String |
getRequestMethod() |
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getRequestParameters() |
java.lang.String |
getRequestScheme() |
java.io.InputStream |
getRequestStream() |
java.net.URI |
getRequestURI() |
java.net.URL |
getResourceURL(java.lang.String path)
Returns the URL of a resource.
|
java.io.OutputStream |
getResponseStream()
Return an OutputStream for the result body.
|
void |
log(java.lang.String message) |
void |
log(java.lang.String message,
java.lang.Throwable ex) |
static void |
parsePostParameters(com.sun.net.httpserver.HttpExchange exchange,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters) |
static void |
parseQuery(java.lang.String query,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters) |
boolean |
reset(boolean headersAlso)
Try to reset (delete) any response generated so far.
|
void |
sendResponseHeaders(int reasonCode,
java.lang.String reasonPhrase,
long responseLength)
Send headers.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Set attribute in the server context.
|
void |
setContentType(java.lang.String type) |
void |
setExchange(com.sun.net.httpserver.HttpExchange exchange,
KawaHttpHandler httpHandler) |
void |
setResponseHeader(java.lang.String name,
java.lang.String value) |
getConsumer, getInstance, getInstance, getLocalIPAddress, getLocalPath, getRequestBodyChars, getRequestParameter, getRequestPath, getRequestPort, getRequestURLBuffer, getScriptPath, normalizeToContext, sendNotFound, setInstance, setScriptAndLocalPathpublic void setExchange(com.sun.net.httpserver.HttpExchange exchange,
KawaHttpHandler httpHandler)
public java.net.URL getResourceURL(java.lang.String path)
HttpRequestContext'/' it is relative to the context path.getResourceURL in class HttpRequestContextpublic java.io.InputStream getRequestStream()
getRequestStream in class HttpRequestContextpublic java.io.OutputStream getResponseStream()
HttpRequestContextgetResponseStream in class HttpRequestContextpublic boolean reset(boolean headersAlso)
HttpRequestContextreset in class HttpRequestContextheadersAlso - if response headers should also be reset.public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getRequestParameters()
getRequestParameters in class HttpRequestContextpublic java.lang.String getRequestHeader(java.lang.String name)
getRequestHeader in class HttpRequestContextpublic java.util.List<java.lang.String> getRequestHeaders(java.lang.String name)
getRequestHeaders in class HttpRequestContextpublic com.sun.net.httpserver.Headers getRequestHeaders()
getRequestHeaders in class HttpRequestContextpublic java.net.URI getRequestURI()
getRequestURI in class HttpRequestContextpublic java.lang.String getContextPath()
HttpRequestContextHttpRequestContext.getRequestPath().
Like ServletContext#getContextPath, but ends with a '/'.
The string getRequestURI() is the same as the concatenation of
getContextPath(), getScriptPath(),
and getLocalPath().getContextPath in class HttpRequestContextpublic java.lang.String getPathTranslated()
getPathTranslated in class HttpRequestContextpublic java.lang.String getRequestScheme()
getRequestScheme in class HttpRequestContextpublic java.net.InetSocketAddress getLocalSocketAddress()
getLocalSocketAddress in class HttpRequestContextpublic java.net.InetAddress getLocalHost()
getLocalHost in class HttpRequestContextpublic int getLocalPort()
getLocalPort in class HttpRequestContextpublic java.net.InetSocketAddress getRemoteSocketAddress()
getRemoteSocketAddress in class HttpRequestContextpublic java.lang.String getRemoteIPAddress()
getRemoteIPAddress in class HttpRequestContextpublic java.net.InetAddress getRemoteHost()
getRemoteHost in class HttpRequestContextpublic int getRemotePort()
getRemotePort in class HttpRequestContextpublic java.lang.String getRequestMethod()
getRequestMethod in class HttpRequestContextpublic java.lang.String getQueryString()
getQueryString in class HttpRequestContextpublic void setResponseHeader(java.lang.String name,
java.lang.String value)
setResponseHeader in class HttpRequestContextpublic void setContentType(java.lang.String type)
setContentType in class HttpRequestContextpublic java.lang.Object getAttribute(java.lang.String name)
HttpRequestContextgetAttribute in class HttpRequestContextpublic void setAttribute(java.lang.String name,
java.lang.Object value)
HttpRequestContextsetAttribute in class HttpRequestContextpublic void sendResponseHeaders(int reasonCode,
java.lang.String reasonPhrase,
long responseLength)
throws java.io.IOException
HttpRequestContextsendResponseHeaders in class HttpRequestContextreasonCode - response code - e.g. 200 for OK.reasonPhrase - response string - e.g. "OK" or "Not Found".responseLength - response length in bytes, or -1 (unspecified).
Note this is different from HttpExchange.sendResponseHeaders.
This method must be called before getResponseStream.
Implementations should set statusCode to STATUS_SENT.java.io.IOExceptionpublic static void parseQuery(java.lang.String query,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingExceptionpublic static void parsePostParameters(com.sun.net.httpserver.HttpExchange exchange,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)
throws java.io.IOException
java.io.IOExceptionpublic void log(java.lang.String message)
log in class HttpRequestContextpublic void log(java.lang.String message,
java.lang.Throwable ex)
log in class HttpRequestContext