Package org.eclipse.jetty.http
Class MimeTypes
- java.lang.Object
-
- org.eclipse.jetty.http.MimeTypes
-
public class MimeTypes extends java.lang.Object
MIME Type enum and utilities
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MimeTypes.Type
-
Field Summary
Fields Modifier and Type Field Description static Trie<MimeTypes.Type>
CACHE
-
Constructor Summary
Constructors Constructor Description MimeTypes()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addMimeMapping(java.lang.String extension, java.lang.String type)
Set a mime mappingstatic java.util.Map<java.lang.String,java.lang.String>
getAssumedEncodings()
Access a mutable map of mime type to the charset assumed for that content type.static java.lang.String
getCharsetAssumedFromContentType(java.lang.String contentType)
static java.lang.String
getCharsetFromContentType(java.lang.String value)
static java.lang.String
getCharsetInferredFromContentType(java.lang.String contentType)
static java.lang.String
getContentTypeWithoutCharset(java.lang.String value)
static java.lang.String
getDefaultMimeByExtension(java.lang.String filename)
Get the MIME type by filename extension.static java.util.Map<java.lang.String,java.lang.String>
getInferredEncodings()
Access a mutable map of mime type to the charset inferred from that content type.static java.util.Set<java.lang.String>
getKnownMimeTypes()
java.lang.String
getMimeByExtension(java.lang.String filename)
Get the MIME type by filename extension.java.util.Map<java.lang.String,java.lang.String>
getMimeMap()
static java.lang.String
inferCharsetFromContentType(java.lang.String contentType)
Deprecated.void
setMimeMap(java.util.Map<java.lang.String,java.lang.String> mimeMap)
-
-
-
Field Detail
-
CACHE
public static final Trie<MimeTypes.Type> CACHE
-
-
Method Detail
-
getMimeMap
public java.util.Map<java.lang.String,java.lang.String> getMimeMap()
-
setMimeMap
public void setMimeMap(java.util.Map<java.lang.String,java.lang.String> mimeMap)
- Parameters:
mimeMap
- A Map of file extension to mime-type.
-
getDefaultMimeByExtension
public static java.lang.String getDefaultMimeByExtension(java.lang.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 java.lang.String getMimeByExtension(java.lang.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(java.lang.String extension, java.lang.String type)
Set a mime mapping- Parameters:
extension
- the extensiontype
- the mime type
-
getKnownMimeTypes
public static java.util.Set<java.lang.String> getKnownMimeTypes()
-
getCharsetFromContentType
public static java.lang.String getCharsetFromContentType(java.lang.String value)
-
getInferredEncodings
public static java.util.Map<java.lang.String,java.lang.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 java.util.Map<java.lang.String,java.lang.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 java.lang.String inferCharsetFromContentType(java.lang.String contentType)
Deprecated.
-
getCharsetInferredFromContentType
public static java.lang.String getCharsetInferredFromContentType(java.lang.String contentType)
-
getCharsetAssumedFromContentType
public static java.lang.String getCharsetAssumedFromContentType(java.lang.String contentType)
-
getContentTypeWithoutCharset
public static java.lang.String getContentTypeWithoutCharset(java.lang.String value)
-
-