Class HttpServletUtils


  • public final class HttpServletUtils
    extends Object
    Various helpers around the HttpServletRequest and HttpServletResponse API.

    Takes care of proxy modifications.

    Since:
    10.7RC1
    Version:
    $Id: 1859fdf703e6848851df24f0f495c821a2e2ad97 $
    • Field Detail

      • HEADER_X_FORWARDED_HOST

        public static final String HEADER_X_FORWARDED_HOST
        Apache stuff, old de-facto standard: X-Forwarded-Host.
        See Also:
        Constant Field Values
      • HEADER_X_FORWARDED_PROTO

        public static final String HEADER_X_FORWARDED_PROTO
        Apache stuff, old de-facto standard: X-Forwarded-Proto.
        See Also:
        Constant Field Values
    • Method Detail

      • getSourceURL

        public static URL getSourceURL​(javax.servlet.http.HttpServletRequest servletRequest)
        Try to extract from various http headers the URL (<protocol>://<host>[:<port>]/<path>[?<querystring>]) as close as possible to the one used by the client.

        In theory HttpServletRequest#getRequestURL() is supposed to take care of all that but depending on the application server and its configuration it's not always reliable. One less thing to configure.

        Parameters:
        servletRequest - the servlet request input
        Returns:
        the URL as close as possible from what the client used
      • getSourceBaseURL

        public static URL getSourceBaseURL​(javax.servlet.http.HttpServletRequest servletRequest)
        Try to extract from various http headers the base URL (<protocol>://<host>[:<port>]) as close as possible to the one used by the client.

        In theory HttpServletRequest#getRequestURL() is supposed to take care of all that but depending on the application server and its configuration it's not always reliable. One less thing to configure.

        Parameters:
        servletRequest - the servlet request input
        Returns:
        the URL as close as possible from what the client used
      • isCacheReadAllowed

        public static boolean isCacheReadAllowed​(javax.servlet.http.HttpServletRequest request)
        Parameters:
        request - the servlet request input
        Returns:
        true if the request explicitly disable getting resources from the cache
        Since:
        11.8RC1