Package kilim.http

Class HttpSession

    • Field Detail

      • pre

        static byte[] pre
      • post

        static byte[] post
    • Constructor Detail

      • HttpSession

        public HttpSession()
    • Method Detail

      • readRequest

        public HttpRequest readRequest​(HttpRequest req)
                                throws java.io.IOException,
                                       Pausable
        Reads the socket, parses the HTTP headers and the body (including chunks) into the req object.
        Parameters:
        req - . The HttpRequest object is reset before filling it in.
        Returns:
        the supplied request object. This is to encourage buffer reuse.
        Throws:
        java.io.IOException
        Pausable
      • sendResponse

        public void sendResponse​(HttpResponse resp)
                          throws java.io.IOException,
                                 Pausable
        Send the response object in its entirety, and mark it for reuse. Often, the resp object may only contain the header, and the body is sent separately. It is the caller's responsibility to make sure that the body matches the header (in terms of encoding, length, chunking etc.)
        Throws:
        java.io.IOException
        Pausable
      • problem

        public void problem​(HttpResponse resp,
                            byte[] statusCode,
                            java.lang.String htmlMsg)
                     throws java.io.IOException,
                            Pausable
        Send an error page to the client.
        Parameters:
        resp - The response object.
        statusCode - See HttpResponse.ST*
        htmlMsg - The body of the message that gives more detail.
        Throws:
        java.io.IOException
        Pausable
      • sendFile

        public int sendFile​(HttpRequest req,
                            HttpResponse resp,
                            java.io.File file,
                            java.lang.String contentType)
                     throws Pausable
        send a file with content length to the client
        Parameters:
        req - the request
        resp - the response
        file - the file to send
        contentType - if non-null, set the content type
        Returns:
        0 on success, 1 for not found, 2 for couldn't send
        Throws:
        Pausable
      • check

        public boolean check​(HttpResponse resp,
                             java.io.File file,
                             java.lang.String... bases)
                      throws java.io.IOException,
                             Pausable
        Throws:
        java.io.IOException
        Pausable