Class MimeTypes


  • public class MimeTypes
    extends Object
    MIME Type enum and utilities
    • Field Detail

      • CACHE

        public static final org.eclipse.jetty.util.Trie<MimeTypes.Type> CACHE
    • Constructor Detail

      • MimeTypes

        public MimeTypes()
        Constructor.
    • Method Detail

      • setMimeMap

        public void setMimeMap​(Map<String,​String> mimeMap)
        Parameters:
        mimeMap - A Map of file extension to mime-type.
      • getDefaultMimeByExtension

        public static String getDefaultMimeByExtension​(String filename)
        Get the MIME type by filename extension. Lookup only the static default mime map.
        Parameters:
        filename - A file name
        Returns:
        MIME type matching the longest dot extension of the file name.
      • getMimeByExtension

        public String getMimeByExtension​(String filename)
        Get the MIME type by filename extension. Lookup the content and static default mime maps.
        Parameters:
        filename - A file name
        Returns:
        MIME type matching the longest dot extension of the file name.
      • addMimeMapping

        public void addMimeMapping​(String extension,
                                   String type)
        Set a mime mapping
        Parameters:
        extension - the extension
        type - the mime type
      • getKnownMimeTypes

        public static Set<String> getKnownMimeTypes()
      • getCharsetFromContentType

        public static String getCharsetFromContentType​(String value)
      • getInferredEncodings

        public static Map<String,​String> getInferredEncodings()
        Access a mutable map of mime type to the charset inferred from that content type. An inferred encoding is used by when encoding/decoding a stream and is explicitly set in any metadata (eg Content-Type).
        Returns:
        Map of mime type to charset
      • getAssumedEncodings

        public static Map<String,​String> getAssumedEncodings()
        Access a mutable map of mime type to the charset assumed for that content type. An assumed encoding is used by when encoding/decoding a stream, but is not explicitly set in any metadata (eg Content-Type).
        Returns:
        Map of mime type to charset
      • inferCharsetFromContentType

        @Deprecated
        public static String inferCharsetFromContentType​(String contentType)
        Deprecated.
      • getCharsetInferredFromContentType

        public static String getCharsetInferredFromContentType​(String contentType)
      • getCharsetAssumedFromContentType

        public static String getCharsetAssumedFromContentType​(String contentType)
      • getContentTypeWithoutCharset

        public static String getContentTypeWithoutCharset​(String value)