1 ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: HUNCHENTOOT; Base: 10 -*-
2 ;;; $Header: /usr/local/cvsrep/hunchentoot/mime-types.lisp,v 1.4 2008/02/13 16:02:18 edi Exp $
4 ;;; Copyright (c) 2004-2008, Dr. Edmund Weitz. All rights reserved.
6 ;;; Redistribution and use in source and binary forms, with or without
7 ;;; modification, are permitted provided that the following conditions
10 ;;; * Redistributions of source code must retain the above copyright
11 ;;; notice, this list of conditions and the following disclaimer.
13 ;;; * Redistributions in binary form must reproduce the above
14 ;;; copyright notice, this list of conditions and the following
15 ;;; disclaimer in the documentation and/or other materials
16 ;;; provided with the distribution.
18 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
19 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 (in-package :hunchentoot
)
32 (defparameter *mime-type-list
* '(("application/andrew-inset" "ez")
33 ("application/cu-seeme" "cu")
34 ("application/dsptype" "tsp")
35 ("application/futuresplash" "spl")
36 ("application/hta" "hta")
37 ("application/java-archive" "jar")
38 ("application/java-serialized-object" "ser")
39 ("application/java-vm" "class")
40 ("application/mac-binhex40" "hqx")
41 ("application/mac-compactpro" "cpt")
42 ("application/mathematica" "nb")
43 ("application/msaccess" "mdb")
44 ("application/msword" "doc" "dot")
45 ("application/octet-stream" "bin")
46 ("application/oda" "oda")
47 ("application/ogg" "ogg")
48 ("application/pdf" "pdf")
49 ("application/pgp-keys" "key")
50 ("application/pgp-signature" "pgp")
51 ("application/pics-rules" "prf")
52 ("application/postscript" "ps" "ai" "eps")
53 ("application/rar" "rar")
54 ("application/rdf+xml" "rdf")
55 ("application/rss+xml" "rss")
56 ("application/smil" "smi" "smil")
57 ("application/wordperfect" "wpd")
58 ("application/wordperfect5.1" "wp5")
59 ("application/xhtml+xml" "xhtml" "xht")
60 ("application/xml" "fo" "xml" "xsl")
61 ("application/zip" "zip")
62 ("application/vnd.cinderella" "cdy")
63 ("application/vnd.mozilla.xul+xml" "xul")
64 ("application/vnd.ms-excel" "xls" "xlb" "xlt")
65 ("application/vnd.ms-pki.seccat" "cat")
66 ("application/vnd.ms-pki.stl" "stl")
67 ("application/vnd.ms-powerpoint" "ppt" "pps")
68 ("application/vnd.oasis.opendocument.chart" "odc")
69 ("application/vnd.oasis.opendocument.database" "odb")
70 ("application/vnd.oasis.opendocument.formula" "odf")
71 ("application/vnd.oasis.opendocument.graphics" "odg")
72 ("application/vnd.oasis.opendocument.graphics-template" "otg")
73 ("application/vnd.oasis.opendocument.image" "odi")
74 ("application/vnd.oasis.opendocument.presentation" "odp")
75 ("application/vnd.oasis.opendocument.presentation-template" "otp")
76 ("application/vnd.oasis.opendocument.spreadsheet" "ods")
77 ("application/vnd.oasis.opendocument.spreadsheet-template" "ots")
78 ("application/vnd.oasis.opendocument.text" "odt")
79 ("application/vnd.oasis.opendocument.text-master" "odm")
80 ("application/vnd.oasis.opendocument.text-template" "ott")
81 ("application/vnd.oasis.opendocument.text-web" "oth")
82 ("application/vnd.rim.cod" "cod")
83 ("application/vnd.smaf" "mmf")
84 ("application/vnd.stardivision.calc" "sdc")
85 ("application/vnd.stardivision.draw" "sda")
86 ("application/vnd.stardivision.impress" "sdd" "sdp")
87 ("application/vnd.stardivision.math" "smf")
88 ("application/vnd.stardivision.writer" "sdw" "vor")
89 ("application/vnd.stardivision.writer-global" "sgl")
90 ("application/vnd.sun.xml.calc" "sxc")
91 ("application/vnd.sun.xml.calc.template" "stc")
92 ("application/vnd.sun.xml.draw" "sxd")
93 ("application/vnd.sun.xml.draw.template" "std")
94 ("application/vnd.sun.xml.impress" "sxi")
95 ("application/vnd.sun.xml.impress.template" "sti")
96 ("application/vnd.sun.xml.math" "sxm")
97 ("application/vnd.sun.xml.writer" "sxw")
98 ("application/vnd.sun.xml.writer.global" "sxg")
99 ("application/vnd.sun.xml.writer.template" "stw")
100 ("application/vnd.symbian.install" "sis")
101 ("application/vnd.visio" "vsd")
102 ("application/vnd.wap.wbxml" "wbxml")
103 ("application/vnd.wap.wmlc" "wmlc")
104 ("application/vnd.wap.wmlscriptc" "wmlsc")
105 ("application/x-123" "wk")
106 ("application/x-abiword" "abw")
107 ("application/x-apple-diskimage" "dmg")
108 ("application/x-bcpio" "bcpio")
109 ("application/x-bittorrent" "torrent")
110 ("application/x-cdf" "cdf")
111 ("application/x-cdlink" "vcd")
112 ("application/x-chess-pgn" "pgn")
113 ("application/x-cpio" "cpio")
114 ("application/x-csh" "csh")
115 ("application/x-debian-package" "deb" "udeb")
116 ("application/x-director" "dcr" "dir" "dxr")
117 ("application/x-dms" "dms")
118 ("application/x-doom" "wad")
119 ("application/x-dvi" "dvi")
120 ("application/x-flac" "flac")
121 ("application/x-font" "pfa" "pfb" "gsf" "pcf")
122 ("application/x-freemind" "mm")
123 ("application/x-futuresplash" "spl")
124 ("application/x-gnumeric" "gnumeric")
125 ("application/x-go-sgf" "sgf")
126 ("application/x-graphing-calculator" "gcf")
127 ("application/x-gtar" "gtar" "tgz" "taz")
128 ("application/x-hdf" "hdf")
129 ("application/x-httpd-php" "phtml" "pht" "php")
130 ("application/x-httpd-php-source" "phps")
131 ("application/x-httpd-php3" "php3")
132 ("application/x-httpd-php3-preprocessed" "php3p")
133 ("application/x-httpd-php4" "php4")
134 ("application/x-ica" "ica")
135 ("application/x-internet-signup" "ins" "isp")
136 ("application/x-iphone" "iii")
137 ("application/x-iso9660-image" "iso")
138 ("application/x-java-jnlp-file" "jnlp")
139 ("application/x-javascript" "js")
140 ("application/x-jmol" "jmz")
141 ("application/x-kchart" "chrt")
142 ("application/x-killustrator" "kil")
143 ("application/x-koan" "skp" "skd" "skt" "skm")
144 ("application/x-kpresenter" "kpr" "kpt")
145 ("application/x-kspread" "ksp")
146 ("application/x-kword" "kwd" "kwt")
147 ("application/x-latex" "latex")
148 ("application/x-lha" "lha")
149 ("application/x-lzh" "lzh")
150 ("application/x-lzx" "lzx")
151 ("application/x-maker" "frm" "maker" "frame" "fm" "fb" "book" "fbdoc")
152 ("application/x-mif" "mif")
153 ("application/x-ms-wmd" "wmd")
154 ("application/x-ms-wmz" "wmz")
155 ("application/x-msdos-program" "com" "exe" "bat" "dll")
156 ("application/x-msi" "msi")
157 ("application/x-netcdf" "nc")
158 ("application/x-ns-proxy-autoconfig" "pac")
159 ("application/x-nwc" "nwc")
160 ("application/x-object" "o")
161 ("application/x-oz-application" "oza")
162 ("application/x-pkcs7-certreqresp" "p7r")
163 ("application/x-pkcs7-crl" "crl")
164 ("application/x-python-code" "pyc" "pyo")
165 ("application/x-quicktimeplayer" "qtl")
166 ("application/x-redhat-package-manager" "rpm")
167 ("application/x-sh" "sh")
168 ("application/x-shar" "shar")
169 ("application/x-shockwave-flash" "swf" "swfl")
170 ("application/x-stuffit" "sit")
171 ("application/x-sv4cpio" "sv4cpio")
172 ("application/x-sv4crc" "sv4crc")
173 ("application/x-tar" "tar")
174 ("application/x-tcl" "tcl")
175 ("application/x-tex-gf" "gf")
176 ("application/x-tex-pk" "pk")
177 ("application/x-texinfo" "texinfo" "texi")
178 ("application/x-trash" "~%" "" "bak" "old" "sik")
179 ("application/x-troff" "tt" "r" "roff")
180 ("application/x-troff-man" "man")
181 ("application/x-troff-me" "me")
182 ("application/x-troff-ms" "ms")
183 ("application/x-ustar" "ustar")
184 ("application/x-wais-source" "src")
185 ("application/x-wingz" "wz")
186 ("application/x-x509-ca-cert" "crt")
187 ("application/x-xcf" "xcf")
188 ("application/x-xfig" "fig")
189 ("application/x-xpinstall" "xpi")
190 ("audio/basic" "au" "snd")
191 ("audio/midi" "mid" "midi" "kar")
192 ("audio/mpeg" "mpga" "mpega" "mp2" "mp3" "m4a")
193 ("audio/mpegurl" "m3u")
194 ("audio/prs.sid" "sid")
195 ("audio/x-aiff" "aif" "aiff" "aifc")
196 ("audio/x-gsm" "gsm")
197 ("audio/x-mpegurl" "m3u")
198 ("audio/x-ms-wma" "wma")
199 ("audio/x-ms-wax" "wax")
200 ("audio/x-pn-realaudio" "ra" "rm" "ram")
201 ("audio/x-realaudio" "ra")
202 ("audio/x-scpls" "pls")
203 ("audio/x-sd2" "sd2")
204 ("audio/x-wav" "wav")
205 ("chemical/x-alchemy" "alc")
206 ("chemical/x-cache" "cac" "cache")
207 ("chemical/x-cache-csf" "csf")
208 ("chemical/x-cactvs-binary" "cbin" "cascii" "ctab")
209 ("chemical/x-cdx" "cdx")
210 ("chemical/x-cerius" "cer")
211 ("chemical/x-chem3d" "c3d")
212 ("chemical/x-chemdraw" "chm")
213 ("chemical/x-cif" "cif")
214 ("chemical/x-cmdf" "cmdf")
215 ("chemical/x-cml" "cml")
216 ("chemical/x-compass" "cpa")
217 ("chemical/x-crossfire" "bsd")
218 ("chemical/x-csml" "csml" "csm")
219 ("chemical/x-ctx" "ctx")
220 ("chemical/x-cxf" "cxf" "cef")
221 ("chemical/x-embl-dl-nucleotide" "emb" "embl")
222 ("chemical/x-galactic-spc" "spc")
223 ("chemical/x-gamess-input" "inp" "gam" "gamin")
224 ("chemical/x-gaussian-checkpoint" "fch" "fchk")
225 ("chemical/x-gaussian-cube" "cub")
226 ("chemical/x-gaussian-input" "gau" "gjc" "gjf")
227 ("chemical/x-gaussian-log" "gal")
228 ("chemical/x-gcg8-sequence" "gcg")
229 ("chemical/x-genbank" "gen")
230 ("chemical/x-hin" "hin")
231 ("chemical/x-isostar" "istr" "ist")
232 ("chemical/x-jcamp-dx" "jdx" "dx")
233 ("chemical/x-kinemage" "kin")
234 ("chemical/x-macmolecule" "mcm")
235 ("chemical/x-macromodel-input" "mmd" "mmod")
236 ("chemical/x-mdl-molfile" "mol")
237 ("chemical/x-mdl-rdfile" "rd")
238 ("chemical/x-mdl-rxnfile" "rxn")
239 ("chemical/x-mdl-sdfile" "sd" "sdf")
240 ("chemical/x-mdl-tgf" "tgf")
241 ("chemical/x-mmcif" "mcif")
242 ("chemical/x-mol2" "mol2")
243 ("chemical/x-molconn-Z" "b")
244 ("chemical/x-mopac-graph" "gpt")
245 ("chemical/x-mopac-input" "mop" "mopcrt" "mpc" "dat" "zmt")
246 ("chemical/x-mopac-out" "moo")
247 ("chemical/x-mopac-vib" "mvb")
248 ("chemical/x-ncbi-asn1" "asn")
249 ("chemical/x-ncbi-asn1-ascii" "prt" "ent")
250 ("chemical/x-ncbi-asn1-binary" "val" "aso")
251 ("chemical/x-ncbi-asn1-spec" "asn")
252 ("chemical/x-pdb" "pdb" "ent")
253 ("chemical/x-rosdal" "ros")
254 ("chemical/x-swissprot" "sw")
255 ("chemical/x-vamas-iso14976" "vms")
256 ("chemical/x-vmd" "vmd")
257 ("chemical/x-xtel" "xtel")
258 ("chemical/x-xyz" "xyz")
261 ("image/jpeg" "jpeg" "jpg" "jpe")
264 ("image/svg+xml" "svg" "svgz")
265 ("image/tiff" "tiff" "tif")
266 ("image/vnd.djvu" "djvu" "djv")
267 ("image/vnd.wap.wbmp" "wbmp")
268 ("image/x-cmu-raster" "ras")
269 ("image/x-coreldraw" "cdr")
270 ("image/x-coreldrawpattern" "pat")
271 ("image/x-coreldrawtemplate" "cdt")
272 ("image/x-corelphotopaint" "cpt")
273 ("image/x-icon" "ico")
275 ("image/x-jng" "jng")
276 ("image/x-ms-bmp" "bmp")
277 ("image/x-photoshop" "psd")
278 ("image/x-portable-anymap" "pnm")
279 ("image/x-portable-bitmap" "pbm")
280 ("image/x-portable-graymap" "pgm")
281 ("image/x-portable-pixmap" "ppm")
282 ("image/x-rgb" "rgb")
283 ("image/x-xbitmap" "xbm")
284 ("image/x-xpixmap" "xpm")
285 ("image/x-xwindowdump" "xwd")
286 ("model/iges" "igs" "iges")
287 ("model/mesh" "msh" "mesh" "silo")
288 ("model/vrml" "wrl" "vrml")
289 ("text/calendar" "ics" "icz")
290 ("text/comma-separated-values" "csv")
293 ("text/html" "html" "htm" "shtml")
295 ("text/mathml" "mml")
296 ("text/plain" "asc" "txt" "text" "diff" "pot")
297 ("text/richtext" "rtx")
299 ("text/scriptlet" "sct" "wsc")
300 ("text/texmacs" "tm" "ts")
301 ("text/tab-separated-values" "tsv")
302 ("text/vnd.sun.j2me.app-descriptor" "jad")
303 ("text/vnd.wap.wml" "wml")
304 ("text/vnd.wap.wmlscript" "wmls")
305 ("text/x-bibtex" "bib")
307 ("text/x-c++hdr" "h++" "hpp" "hxx" "hh")
308 ("text/x-c++src" "c++" "cpp" "cxx" "cc")
310 ("text/x-component" "htc")
314 ("text/x-haskell" "hs")
315 ("text/x-java" "java")
316 ("text/x-literate-haskell" "lhs")
318 ("text/x-pascal" "pp" "as")
319 ("text/x-pcs-gcd" "gcd")
320 ("text/x-perl" "pl" "pm")
321 ("text/x-python" "py")
322 ("text/x-setext" "etx")
324 ("text/x-tcl" "tcl" "tk")
325 ("text/x-tex" "tex" "ltx" "sty" "cls")
326 ("text/x-vcalendar" "vcs")
327 ("text/x-vcard" "vcf")
329 ("video/dv" "dif" "dv")
332 ("video/mpeg" "mpeg" "mpg" "mpe")
334 ("video/quicktime" "qt" "mov")
335 ("video/vnd.mpegurl" "mxu")
336 ("video/x-la-asf" "lsf" "lsx")
337 ("video/x-mng" "mng")
338 ("video/x-ms-asf" "asf" "asx")
339 ("video/x-ms-wm" "wm")
340 ("video/x-ms-wmv" "wmv")
341 ("video/x-ms-wmx" "wmx")
342 ("video/x-ms-wvx" "wvx")
343 ("video/x-msvideo" "avi")
344 ("video/x-sgi-movie" "movie")
345 ("x-conference/x-cooltalk" "ice")
346 ("x-world/x-vrml" "vrm" "vrml" "wrl"))
347 "An alist where the cars are MIME types and the cdrs are list
348 of file suffixes for the corresponding type.")
350 (defparameter *mime-type-hash
*
351 (let ((hash (make-hash-table :test
#'equalp
)))
352 (loop for
(type . suffixes
) in
*mime-type-list
* do
353 (loop for suffix in suffixes do
354 (setf (gethash suffix hash
) type
)))
356 "A hash table which maps file suffixes to MIME types.")
358 (defun mime-type (pathspec)
359 "Given a pathname designator PATHSPEC returns the MIME type
360 \(as a string) corresponding to the suffix of the file denoted by
362 (gethash (pathname-type pathspec
) *mime-type-hash
*))