Class HttpUtils


  • public class HttpUtils
    extends java.lang.Object
    This class provides static utility methods to eliminate Web Veracode false alarm for CWE ID 113 Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting').
    Since:
    MicroStrategy Web 11.3.1
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addCookie​(javax.servlet.http.HttpServletResponse response, javax.servlet.http.Cookie cookie)
      The default behavior of this method is to call addCookie(Cookie cookie)
      static void addHeader​(javax.servlet.http.HttpServletResponse response, java.lang.String name, java.lang.String value)
      The default behavior of this method is to return addHeader(String name, String value)
      static boolean is2xxSuccessful​(int statusCode)
      Whether this status code is in the range of 2xx
      static void sendRedirect​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String location)
      The default behavior of this method is to return sendRedirect(String location)
      static void setContentType​(javax.servlet.ServletResponse response, java.lang.String type)
      Sets the content type of the response being sent to the client
      static void setHeader​(javax.servlet.http.HttpServletResponse response, java.lang.String name, java.lang.String value)
      The default behavior of this method is to return setHeader(String name, String value)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • sendRedirect

        public static void sendRedirect​(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        java.lang.String location)
                                 throws java.io.IOException
        The default behavior of this method is to return sendRedirect(String location)
        Parameters:
        response - HttpServletResponse
        location - the redirect location URL
        Throws:
        java.io.IOException - If an input or output exception occurs
      • setHeader

        public static void setHeader​(javax.servlet.http.HttpServletResponse response,
                                     java.lang.String name,
                                     java.lang.String value)
        The default behavior of this method is to return setHeader(String name, String value)
        Parameters:
        response - HttpServletResponse
        name - the name of the header
        value - the header value If it contains octet string
      • addHeader

        public static void addHeader​(javax.servlet.http.HttpServletResponse response,
                                     java.lang.String name,
                                     java.lang.String value)
        The default behavior of this method is to return addHeader(String name, String value)
        Parameters:
        response - HttpServletResponse
        name - the name of the header
        value - the header value If it contains octet string
      • addCookie

        public static void addCookie​(javax.servlet.http.HttpServletResponse response,
                                     javax.servlet.http.Cookie cookie)
        The default behavior of this method is to call addCookie(Cookie cookie)
        Parameters:
        response - HttpServletResponse
        cookie - the Cookie to return to the client
      • setContentType

        public static void setContentType​(javax.servlet.ServletResponse response,
                                          java.lang.String type)
        Sets the content type of the response being sent to the client
        Parameters:
        response - ServletResponse
        type - a String specifying the MIME type of the content
      • is2xxSuccessful

        public static boolean is2xxSuccessful​(int statusCode)
        Whether this status code is in the range of 2xx
        Parameters:
        statusCode -
        Returns:
        true if statusCode is in the range of 2xx