1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2013 Justin Michaud-Ouellette
4 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # Services to identify Internet media types (or MIME types, Content-types)
21 # Map of known MIME types
24 # MIME types by extensions.
25 protected var types
= new HashMap[String, String]
27 # Get the type/subtype associated to a file extension `ext`
28 fun [](ext
: String): nullable String
30 if types
.keys
.has
(ext
) then return types
[ext
]
36 types
["html"] = "text/html"
37 types
["htm"] = "text/html"
38 types
["shtml"] = "text/html"
39 types
["css"] = "text/css"
40 types
["csv"] = "text/csv"
41 types
["xml"] = "text/xml"
42 types
["rss"] = "text/xml"
43 types
["gif"] = "image/gif"
44 types
["jpg"] = "image/jpeg"
45 types
["jpeg"] = "image/jpeg"
46 types
["js"] = "application/x-javascript"
47 types
["txt"] = "text/plain"
48 types
["htc"] = "text/x-component"
49 types
["mml"] = "text/mathml"
50 types
["png"] = "image/png"
51 types
["ico"] = "image/x-icon"
52 types
["jng"] = "image/x-jng"
53 types
["wbmp"] = "image/vnd.wap.wbmp"
54 types
["gz"] = "application/gzip"
55 types
["jar"] = "application/java-archive"
56 types
["war"] = "application/java-archive"
57 types
["ear"] = "application/java-archive"
58 types
["json"] = "application/json"
59 types
["hqx"] = "application/mac-binhex40"
60 types
["pdf"] = "application/pdf"
61 types
["cco"] = "application/x-cocoa"
62 types
["jardiff"] = "application/x-java-archive-diff"
63 types
["jnlp"] = "application/x-java-jnlp-file"
64 types
["run"] = "application/x-makeself"
65 types
["pl"] = "application/x-perl"
66 types
["pm"] = "application/x-perl"
67 types
["pdb"] = "application/x-pilot"
68 types
["prc"] = "application/x-pilot"
69 types
["rar"] = "application/x-rar-compressed"
70 types
["rpm"] = "application/x-redhat-package-manager"
71 types
["sea"] = "application/x-sea"
72 types
["swf"] = "application/x-shockwave-flash"
73 types
["sit"] = "application/x-stuffit"
74 types
["tcl"] = "application/x-tcl"
75 types
["tk"] = "application/x-tcl"
76 types
["der"] = "application/x-x509-ca-cert"
77 types
["pem"] = "application/x-x509-ca-cert"
78 types
["crt"] = "application/x-x509-ca-cert"
79 types
["xpi"] = "application/x-xpinstall"
80 types
["zip"] = "application/zip"
81 types
["deb"] = "application/octet-stream"
82 types
["bin"] = "application/octet-stream"
83 types
["exe"] = "application/octet-stream"
84 types
["dll"] = "application/octet-stream"
85 types
["dmg"] = "application/octet-stream"
86 types
["eot"] = "application/octet-stream"
87 types
["iso"] = "application/octet-stream"
88 types
["img"] = "application/octet-stream"
89 types
["msi"] = "application/octet-stream"
90 types
["msp"] = "application/octet-stream"
91 types
["msm"] = "application/octet-stream"
92 types
["mp3"] = "audio/mpeg"
93 types
["ra"] = "audio/x-realaudio"
94 types
["mpeg"] = "video/mpeg"
95 types
["mpg"] = "video/mpeg"
96 types
["mov"] = "video/quicktime"
97 types
["flv"] = "video/x-flv"
98 types
["avi"] = "video/x-msvideo"
99 types
["wmv"] = "video/x-ms-wmv"
100 types
["asx"] = "video/x-ms-asf"
101 types
["asf"] = "video/x-ms-asf"
102 types
["mng"] = "video/x-mng"
103 types
["apk"] = "application/vnd.android.package-archive"
104 types
["svg"] = "image/svg+xml"
105 types
["ttf"] = "application/x-font-ttf"
106 types
["otf"] = "application/x-font-opentype"
107 types
["eof"] = "application/vnd.ms-fontobject"
108 types
["woff"] = "application/font-woff"
109 types
["woff2"] = "application/font-woff2"
114 fun media_types
: MediaTypes do return once
new MediaTypes