Package gnu.kawa.servlet
Class KawaHttpHandler.Context
java.lang.Object
gnu.kawa.servlet.HttpRequestContext
gnu.kawa.servlet.KawaHttpHandler.Context
- Enclosing class:
KawaHttpHandler
-
Field Summary
Fields inherited from class gnu.kawa.servlet.HttpRequestContext
HTTP_NOT_FOUND, HTTP_OK, importServletDefinitions, instance, statusCode, statusReasonPhrase
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute
(String name) Get attribute from the server context.Returns the context path, relative to the server root.int
int
getRequestHeader
(String name) getRequestHeaders
(String name) getResourceURL
(String path) Returns the URL of a resource.Return an OutputStream for the result body.void
void
static void
parsePostParameters
(HttpExchange exchange, Map<String, List<String>> parameters) static void
boolean
reset
(boolean headersAlso) Try to reset (delete) any response generated so far.void
sendResponseHeaders
(int reasonCode, String reasonPhrase, long responseLength) Send headers.void
setAttribute
(String name, Object value) Set attribute in the server context.void
setContentType
(String type) void
setExchange
(HttpExchange exchange, KawaHttpHandler httpHandler) void
setResponseHeader
(String name, 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
-
Constructor Details
-
Context
public Context()
-
-
Method Details
-
setExchange
-
getResourceURL
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
- Specified by:
getRequestStream
in classHttpRequestContext
-
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
- Specified by:
getRequestParameters
in classHttpRequestContext
-
getRequestHeader
- Specified by:
getRequestHeader
in classHttpRequestContext
-
getRequestHeaders
- Specified by:
getRequestHeaders
in classHttpRequestContext
-
getRequestHeaders
- Specified by:
getRequestHeaders
in classHttpRequestContext
-
getRequestURI
- Specified by:
getRequestURI
in classHttpRequestContext
-
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
- Specified by:
getPathTranslated
in classHttpRequestContext
-
getRequestScheme
- Overrides:
getRequestScheme
in classHttpRequestContext
-
getLocalSocketAddress
- Overrides:
getLocalSocketAddress
in classHttpRequestContext
-
getLocalHost
- Overrides:
getLocalHost
in classHttpRequestContext
-
getLocalPort
public int getLocalPort()- Specified by:
getLocalPort
in classHttpRequestContext
-
getRemoteSocketAddress
- Overrides:
getRemoteSocketAddress
in classHttpRequestContext
-
getRemoteIPAddress
- Specified by:
getRemoteIPAddress
in classHttpRequestContext
-
getRemoteHost
- Specified by:
getRemoteHost
in classHttpRequestContext
-
getRemotePort
public int getRemotePort()- Specified by:
getRemotePort
in classHttpRequestContext
-
getRequestMethod
- Specified by:
getRequestMethod
in classHttpRequestContext
-
getQueryString
- Specified by:
getQueryString
in classHttpRequestContext
-
setResponseHeader
- Specified by:
setResponseHeader
in classHttpRequestContext
-
setContentType
- Overrides:
setContentType
in classHttpRequestContext
-
getAttribute
Description copied from class:HttpRequestContext
Get attribute from the server context.- Specified by:
getAttribute
in classHttpRequestContext
-
setAttribute
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
- Specified by:
log
in classHttpRequestContext
-
log
- Specified by:
log
in classHttpRequestContext
-