Class RequestUtil


  • public class RequestUtil
    extends Object
    Utilities for manipulating HTTP request objects.
    • Method Detail

      • setErrorTraceAttribute

        public static void setErrorTraceAttribute​(javax.servlet.http.HttpServletRequest req,
                                                  Throwable t)
      • getErrorTraceAttribute

        public static Throwable getErrorTraceAttribute​(javax.servlet.http.HttpServletRequest req)
      • getEncodedPathInfo

        public static String getEncodedPathInfo​(javax.servlet.http.HttpServletRequest req)
        Returns:
        the same value as HttpServletRequest.getPathInfo(), but without decoding URL-encoded characters.
      • getRestPathWithoutIds

        public static String getRestPathWithoutIds​(javax.servlet.http.HttpServletRequest req)
        Trims leading '/' and 'a/'. Removes the context path, but keeps the servlet path. Removes all IDs from the rest of the URI.

        The returned string is a good fit for cases where one wants the full context of the request without any identifiable data. For example: Logging or quota checks.

        Examples:

        • /a/accounts/self/detail => /accounts/detail
        • /changes/123/revisions/current/detail => /changes/revisions/detail
        • /changes/ => /changes
      • acceptsGzipEncoding

        public static boolean acceptsGzipEncoding​(javax.servlet.http.HttpServletRequest request)