Package gnu.kawa.servlet
Class KawaHttpHandler.Context
- java.lang.Object
-
- gnu.kawa.servlet.HttpRequestContext
-
- gnu.kawa.servlet.KawaHttpHandler.Context
-
- Enclosing class:
- KawaHttpHandler
public static class KawaHttpHandler.Context extends HttpRequestContext
-
-
Field Summary
-
Fields inherited from class gnu.kawa.servlet.HttpRequestContext
HTTP_NOT_FOUND, HTTP_OK, importServletDefinitions, instance, statusCode, statusReasonPhrase
-
-
Constructor Summary
Constructors Constructor Description Context()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetAttribute(java.lang.String name)Get attribute from the server context.java.lang.StringgetContextPath()Returns the context path, relative to the server root.java.net.InetAddressgetLocalHost()intgetLocalPort()java.net.InetSocketAddressgetLocalSocketAddress()java.lang.StringgetPathTranslated()java.lang.StringgetQueryString()java.net.InetAddressgetRemoteHost()java.lang.StringgetRemoteIPAddress()intgetRemotePort()java.net.InetSocketAddressgetRemoteSocketAddress()java.lang.StringgetRequestHeader(java.lang.String name)com.sun.net.httpserver.HeadersgetRequestHeaders()java.util.List<java.lang.String>getRequestHeaders(java.lang.String name)java.lang.StringgetRequestMethod()java.util.Map<java.lang.String,java.util.List<java.lang.String>>getRequestParameters()java.lang.StringgetRequestScheme()java.io.InputStreamgetRequestStream()java.net.URIgetRequestURI()java.net.URLgetResourceURL(java.lang.String path)Returns the URL of a resource.java.io.OutputStreamgetResponseStream()Return an OutputStream for the result body.voidlog(java.lang.String message)voidlog(java.lang.String message, java.lang.Throwable ex)static voidparsePostParameters(com.sun.net.httpserver.HttpExchange exchange, java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)static voidparseQuery(java.lang.String query, java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)booleanreset(boolean headersAlso)Try to reset (delete) any response generated so far.voidsendResponseHeaders(int reasonCode, java.lang.String reasonPhrase, long responseLength)Send headers.voidsetAttribute(java.lang.String name, java.lang.Object value)Set attribute in the server context.voidsetContentType(java.lang.String type)voidsetExchange(com.sun.net.httpserver.HttpExchange exchange, KawaHttpHandler httpHandler)voidsetResponseHeader(java.lang.String name, java.lang.String value)-
Methods inherited from class gnu.kawa.servlet.HttpRequestContext
getConsumer, getInstance, getInstance, getLocalIPAddress, getLocalPath, getRequestBodyChars, getRequestParameter, getRequestPath, getRequestPort, getRequestURLBuffer, getScriptPath, handleStaticFile, normalizeToContext, sendNotFound, setInstance, setScriptAndLocalPath
-
-
-
-
Method Detail
-
setExchange
public void setExchange(com.sun.net.httpserver.HttpExchange exchange, KawaHttpHandler httpHandler)
-
getResourceURL
public java.net.URL getResourceURL(java.lang.String path)
Description copied from class:HttpRequestContextReturns the URL of a resource. The resource is relative to the script path, if the path is relative; otherwise (if it starts with a'/'it is relative to the context path.- Specified by:
getResourceURLin classHttpRequestContext
-
getRequestStream
public java.io.InputStream getRequestStream()
- Specified by:
getRequestStreamin classHttpRequestContext
-
getResponseStream
public java.io.OutputStream getResponseStream()
Description copied from class:HttpRequestContextReturn an OutputStream for the result body. Multiple calls will return the same OutputStream.- Specified by:
getResponseStreamin classHttpRequestContext
-
reset
public boolean reset(boolean headersAlso)
Description copied from class:HttpRequestContextTry to reset (delete) any response generated so far.- Specified by:
resetin classHttpRequestContext- Parameters:
headersAlso- if response headers should also be reset.- Returns:
- true on success, false if it's too late.
-
getRequestParameters
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getRequestParameters()
- Specified by:
getRequestParametersin classHttpRequestContext
-
getRequestHeader
public java.lang.String getRequestHeader(java.lang.String name)
- Specified by:
getRequestHeaderin classHttpRequestContext
-
getRequestHeaders
public java.util.List<java.lang.String> getRequestHeaders(java.lang.String name)
- Specified by:
getRequestHeadersin classHttpRequestContext
-
getRequestHeaders
public com.sun.net.httpserver.Headers getRequestHeaders()
- Specified by:
getRequestHeadersin classHttpRequestContext
-
getRequestURI
public java.net.URI getRequestURI()
- Specified by:
getRequestURIin classHttpRequestContext
-
getContextPath
public java.lang.String getContextPath()
Description copied from class:HttpRequestContextReturns the context path, relative to the server root. This is an initial substring of theHttpRequestContext.getRequestPath(). LikeServletContext#getContextPath, but ends with a'/'. The stringgetRequestURI()is the same as the concatenation ofgetContextPath(),getScriptPath(), andgetLocalPath().- Specified by:
getContextPathin classHttpRequestContext
-
getPathTranslated
public java.lang.String getPathTranslated()
- Specified by:
getPathTranslatedin classHttpRequestContext
-
getRequestScheme
public java.lang.String getRequestScheme()
- Overrides:
getRequestSchemein classHttpRequestContext
-
getLocalSocketAddress
public java.net.InetSocketAddress getLocalSocketAddress()
- Overrides:
getLocalSocketAddressin classHttpRequestContext
-
getLocalHost
public java.net.InetAddress getLocalHost()
- Overrides:
getLocalHostin classHttpRequestContext
-
getLocalPort
public int getLocalPort()
- Specified by:
getLocalPortin classHttpRequestContext
-
getRemoteSocketAddress
public java.net.InetSocketAddress getRemoteSocketAddress()
- Overrides:
getRemoteSocketAddressin classHttpRequestContext
-
getRemoteIPAddress
public java.lang.String getRemoteIPAddress()
- Specified by:
getRemoteIPAddressin classHttpRequestContext
-
getRemoteHost
public java.net.InetAddress getRemoteHost()
- Specified by:
getRemoteHostin classHttpRequestContext
-
getRemotePort
public int getRemotePort()
- Specified by:
getRemotePortin classHttpRequestContext
-
getRequestMethod
public java.lang.String getRequestMethod()
- Specified by:
getRequestMethodin classHttpRequestContext
-
getQueryString
public java.lang.String getQueryString()
- Specified by:
getQueryStringin classHttpRequestContext
-
setResponseHeader
public void setResponseHeader(java.lang.String name, java.lang.String value)- Specified by:
setResponseHeaderin classHttpRequestContext
-
setContentType
public void setContentType(java.lang.String type)
- Overrides:
setContentTypein classHttpRequestContext
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Description copied from class:HttpRequestContextGet attribute from the server context.- Specified by:
getAttributein classHttpRequestContext
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)Description copied from class:HttpRequestContextSet attribute in the server context.- Specified by:
setAttributein classHttpRequestContext
-
sendResponseHeaders
public void sendResponseHeaders(int reasonCode, java.lang.String reasonPhrase, long responseLength) throws java.io.IOExceptionDescription copied from class:HttpRequestContextSend headers.- Specified by:
sendResponseHeadersin classHttpRequestContext- Parameters:
reasonCode- 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.- Throws:
java.io.IOException
-
parseQuery
public static void parseQuery(java.lang.String query, java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters) throws java.io.UnsupportedEncodingException- Throws:
java.io.UnsupportedEncodingException
-
parsePostParameters
public 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- Throws:
java.io.IOException
-
log
public void log(java.lang.String message)
- Specified by:
login classHttpRequestContext
-
log
public void log(java.lang.String message, java.lang.Throwable ex)- Specified by:
login classHttpRequestContext
-
-