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
-
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(HttpExchange exchange, KawaHttpHandler httpHandler)
-
getResourceURL
public URL getResourceURL(String path)
Description copied from class:HttpRequestContext
Returns 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:
getResourceURL
in classHttpRequestContext
-
getRequestStream
public InputStream getRequestStream()
- Specified by:
getRequestStream
in classHttpRequestContext
-
getResponseStream
public OutputStream getResponseStream()
Description copied from class:HttpRequestContext
Return an OutputStream for the result body. Multiple calls will return the same OutputStream.- Specified by:
getResponseStream
in classHttpRequestContext
-
reset
public boolean reset(boolean headersAlso)
Description copied from class:HttpRequestContext
Try to reset (delete) any response generated so far.- Specified by:
reset
in classHttpRequestContext
- Parameters:
headersAlso
- if response headers should also be reset.- Returns:
- true on success, false if it's too late.
-
getRequestParameters
public Map<String,List<String>> getRequestParameters()
- Specified by:
getRequestParameters
in classHttpRequestContext
-
getRequestHeader
public String getRequestHeader(String name)
- Specified by:
getRequestHeader
in classHttpRequestContext
-
getRequestHeaders
public List<String> getRequestHeaders(String name)
- Specified by:
getRequestHeaders
in classHttpRequestContext
-
getRequestHeaders
public Headers getRequestHeaders()
- Specified by:
getRequestHeaders
in classHttpRequestContext
-
getRequestURI
public URI getRequestURI()
- Specified by:
getRequestURI
in classHttpRequestContext
-
getContextPath
public String getContextPath()
Description copied from class:HttpRequestContext
Returns 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:
getContextPath
in classHttpRequestContext
-
getPathTranslated
public String getPathTranslated()
- Specified by:
getPathTranslated
in classHttpRequestContext
-
getRequestScheme
public String getRequestScheme()
- Overrides:
getRequestScheme
in classHttpRequestContext
-
getLocalSocketAddress
public InetSocketAddress getLocalSocketAddress()
- Overrides:
getLocalSocketAddress
in classHttpRequestContext
-
getLocalHost
public InetAddress getLocalHost()
- Overrides:
getLocalHost
in classHttpRequestContext
-
getLocalPort
public int getLocalPort()
- Specified by:
getLocalPort
in classHttpRequestContext
-
getRemoteSocketAddress
public InetSocketAddress getRemoteSocketAddress()
- Overrides:
getRemoteSocketAddress
in classHttpRequestContext
-
getRemoteIPAddress
public String getRemoteIPAddress()
- Specified by:
getRemoteIPAddress
in classHttpRequestContext
-
getRemoteHost
public InetAddress getRemoteHost()
- Specified by:
getRemoteHost
in classHttpRequestContext
-
getRemotePort
public int getRemotePort()
- Specified by:
getRemotePort
in classHttpRequestContext
-
getRequestMethod
public String getRequestMethod()
- Specified by:
getRequestMethod
in classHttpRequestContext
-
getQueryString
public String getQueryString()
- Specified by:
getQueryString
in classHttpRequestContext
-
setResponseHeader
public void setResponseHeader(String name, String value)
- Specified by:
setResponseHeader
in classHttpRequestContext
-
setContentType
public void setContentType(String type)
- Overrides:
setContentType
in classHttpRequestContext
-
getAttribute
public Object getAttribute(String name)
Description copied from class:HttpRequestContext
Get attribute from the server context.- Specified by:
getAttribute
in classHttpRequestContext
-
setAttribute
public void setAttribute(String name, Object value)
Description copied from class:HttpRequestContext
Set attribute in the server context.- Specified by:
setAttribute
in classHttpRequestContext
-
sendResponseHeaders
public void sendResponseHeaders(int reasonCode, String reasonPhrase, long responseLength) throws IOException
Description copied from class:HttpRequestContext
Send headers.- Specified by:
sendResponseHeaders
in 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:
IOException
-
parseQuery
public static void parseQuery(String query, Map<String,List<String>> parameters) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
parsePostParameters
public static void parsePostParameters(HttpExchange exchange, Map<String,List<String>> parameters) throws IOException
- Throws:
IOException
-
log
public void log(String message)
- Specified by:
log
in classHttpRequestContext
-
log
public void log(String message, Throwable ex)
- Specified by:
log
in classHttpRequestContext
-
-