Class ServletUtils

    • Method Detail

      • createHTTPRequest

        public static HTTPRequest createHTTPRequest​(javax.servlet.http.HttpServletRequest sr)
                                             throws IOException
        Creates a new HTTP request from the specified HTTP servlet request.

        Warning about servlet filters: Processing of HTTP POST and PUT requests requires the entity body to be available for reading from the HttpServletRequest. If you're getting unexpected exceptions, please ensure the entity body is not consumed or modified by an upstream servlet filter.

        Parameters:
        sr - The servlet request. Must not be null.
        Returns:
        The HTTP request.
        Throws:
        IllegalArgumentException - The the servlet request method is not GET, POST, PUT or DELETE or the content type header value couldn't be parsed.
        IOException - For a POST or PUT body that couldn't be read due to an I/O exception.
      • createHTTPRequest

        public static HTTPRequest createHTTPRequest​(javax.servlet.http.HttpServletRequest sr,
                                                    long maxEntityLength)
                                             throws IOException
        Creates a new HTTP request from the specified HTTP servlet request.

        Warning about servlet filters: Processing of HTTP POST and PUT requests requires the entity body to be available for reading from the HttpServletRequest. If you're getting unexpected exceptions, please ensure the entity body is not consumed or modified by an upstream servlet filter.

        Parameters:
        sr - The servlet request. Must not be null.
        maxEntityLength - The maximum entity length to accept, -1 for no limit.
        Returns:
        The HTTP request.
        Throws:
        IllegalArgumentException - The the servlet request method is not GET, POST, PUT or DELETE or the content type header value couldn't be parsed.
        IOException - For a POST or PUT body that couldn't be read due to an I/O exception.
      • applyHTTPResponse

        public static void applyHTTPResponse​(HTTPResponse httpResponse,
                                             javax.servlet.http.HttpServletResponse servletResponse)
                                      throws IOException
        Applies the status code, headers and content of the specified HTTP response to a HTTP servlet response.
        Parameters:
        httpResponse - The HTTP response. Must not be null.
        servletResponse - The HTTP servlet response. Must not be null.
        Throws:
        IOException - If the response content couldn't be written.
      • extractClientX509Certificate

        public static X509Certificate extractClientX509Certificate​(javax.servlet.ServletRequest servletRequest)
        Extracts the client's X.509 certificate from the specified servlet request. The first found certificate is returned, if any.
        Parameters:
        servletRequest - The HTTP servlet request. Must not be null.
        Returns:
        The first client X.509 certificate, null if none is found.