Class KawaHttpHandler.Context
java.lang.Object
gnu.kawa.servlet.HttpRequestContext
gnu.kawa.servlet.KawaHttpHandler.Context
- Enclosing class:
KawaHttpHandler
-
Field Summary
Fields inherited from class 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.intintgetRequestHeader(String name) com.sun.net.httpserver.HeadersgetRequestHeaders(String name) getResourceURL(String path) Returns the URL of a resource.Return an OutputStream for the result body.voidvoidstatic voidparsePostParameters(com.sun.net.httpserver.HttpExchange exchange, Map<String, List<String>> parameters) static voidbooleanreset(boolean headersAlso) Try to reset (delete) any response generated so far.voidsendResponseHeaders(int reasonCode, String reasonPhrase, long responseLength) Send headers.voidsetAttribute(String name, Object value) Set attribute in the server context.voidsetContentType(String type) voidsetExchange(com.sun.net.httpserver.HttpExchange exchange, KawaHttpHandler httpHandler) voidsetResponseHeader(String name, String value) Methods inherited from class 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: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
- Specified by:
getRequestStreamin classHttpRequestContext
-
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
- Specified by:
getRequestParametersin classHttpRequestContext
-
getRequestHeader
- Specified by:
getRequestHeaderin classHttpRequestContext
-
getRequestHeaders
- Specified by:
getRequestHeadersin classHttpRequestContext
-
getRequestHeaders
public com.sun.net.httpserver.Headers getRequestHeaders()- Specified by:
getRequestHeadersin classHttpRequestContext
-
getRequestURI
- Specified by:
getRequestURIin classHttpRequestContext
-
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
- Specified by:
getPathTranslatedin classHttpRequestContext
-
getRequestScheme
- Overrides:
getRequestSchemein classHttpRequestContext
-
getLocalSocketAddress
- Overrides:
getLocalSocketAddressin classHttpRequestContext
-
getLocalHost
- Overrides:
getLocalHostin classHttpRequestContext
-
getLocalPort
public int getLocalPort()- Specified by:
getLocalPortin classHttpRequestContext
-
getRemoteSocketAddress
- Overrides:
getRemoteSocketAddressin classHttpRequestContext
-
getRemoteIPAddress
- Specified by:
getRemoteIPAddressin classHttpRequestContext
-
getRemoteHost
- Specified by:
getRemoteHostin classHttpRequestContext
-
getRemotePort
public int getRemotePort()- Specified by:
getRemotePortin classHttpRequestContext
-
getRequestMethod
- Specified by:
getRequestMethodin classHttpRequestContext
-
getQueryString
- Specified by:
getQueryStringin classHttpRequestContext
-
setResponseHeader
- Specified by:
setResponseHeaderin classHttpRequestContext
-
setContentType
- Overrides:
setContentTypein classHttpRequestContext
-
getAttribute
Description copied from class:HttpRequestContextGet attribute from the server context.- Specified by:
getAttributein classHttpRequestContext
-
setAttribute
Description copied from class:HttpRequestContextSet attribute in the server context.- Specified by:
setAttributein classHttpRequestContext
-
sendResponseHeaders
public void sendResponseHeaders(int reasonCode, String reasonPhrase, long responseLength) throws IOException Description 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:
IOException
-
parseQuery
public static void parseQuery(String query, Map<String, List<String>> parameters) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
parsePostParameters
public static void parsePostParameters(com.sun.net.httpserver.HttpExchange exchange, Map<String, List<String>> parameters) throws IOException - Throws:
IOException
-
log
- Specified by:
login classHttpRequestContext
-
log
- Specified by:
login classHttpRequestContext
-