Class KawaHttpHandler.Context

    • Constructor Detail

      • Context

        public Context()
    • 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: 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 class HttpRequestContext
      • getResponseStream

        public java.io.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 class HttpRequestContext
      • reset

        public boolean reset​(boolean headersAlso)
        Description copied from class: HttpRequestContext
        Try to reset (delete) any response generated so far.
        Specified by:
        reset in class HttpRequestContext
        Parameters:
        headersAlso - if response headers should also be reset.
        Returns:
        true on success, false if it's too late.
      • getContextPath

        public java.lang.String getContextPath()
        Description copied from class: HttpRequestContext
        Returns the context path, relative to the server root. This is an initial substring of the HttpRequestContext.getRequestPath(). Like ServletContext#getContextPath, but ends with a '/'. The string getRequestURI() is the same as the concatenation of getContextPath(), getScriptPath(), and getLocalPath().
        Specified by:
        getContextPath in class HttpRequestContext
      • sendResponseHeaders

        public void sendResponseHeaders​(int reasonCode,
                                        java.lang.String reasonPhrase,
                                        long responseLength)
                                 throws java.io.IOException
        Description copied from class: HttpRequestContext
        Send headers.
        Specified by:
        sendResponseHeaders in class HttpRequestContext
        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,
                        java.lang.Throwable ex)
        Specified by:
        log in class HttpRequestContext