Package ninja.utils

Class HttpHeaderUtils


  • public class HttpHeaderUtils
    extends Object
    • Constructor Detail

      • HttpHeaderUtils

        public HttpHeaderUtils()
    • Method Detail

      • getContentTypeFromContentTypeAndCharacterSetting

        public static String getContentTypeFromContentTypeAndCharacterSetting​(String rawContentType)
        A http content type should contain a character set like "application/json; charset=utf-8". If you only want to get "application/json" you can use this method. See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1
        Parameters:
        rawContentType - "application/json; charset=utf-8" or "application/json"
        Returns:
        only the contentType without charset. Eg "application/json"
      • getCharsetOfContentType

        public static String getCharsetOfContentType​(String rawContentType,
                                                     String defaultEncoding)
        A http content type should contain a character set like "application/json; charset=utf-8". If you only want to get the character set you can use this method. See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1
        Parameters:
        rawContentType - "application/json; charset=utf-8" or "application/json"
        Returns:
        only the character set like utf-8 OR the defaultEncoding when not set
      • getCharsetOfContentTypeOrUtf8

        public static String getCharsetOfContentTypeOrUtf8​(String rawContentType)
        A http content type should contain a character set like "application/json; charset=utf-8". If you only want to get the character set you can use this method. See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1
        Parameters:
        rawContentType - "application/json; charset=utf-8" or "application/json"
        Returns:
        only the character set like utf-8 OR utf-8 when not set