1 //Written in the D programming language 2 /* 3 * MIME Types. 4 * 5 * Copyright: Copyright (C) 2015 Jaypha 6 * 7 * Distributed under the Boost Software License, Version 1.0. 8 * (See http://www.boost.org/LICENSE_1_0.txt) 9 * 10 * Authors: Jason den Dulk 11 */ 12 13 /* 14 * To get all mime types defined, compile with version=allMimeTypes. 15 * Otherwise a subset of the most common mime types will be compiled. 16 */ 17 18 module jaypha.inet.mime.types; 19 20 import std.path; 21 import std.string; 22 import std.exception; 23 24 immutable string[string] fileExtMimeTypes; 25 26 shared static this() 27 { 28 version(allMimeTypes) 29 { 30 // All mime types (supplied via source JSON) 31 32 auto mx = 33 [ 34 "123" : "application/vnd.lotus-1-2-3", 35 "3dml" : "text/vnd.in3d.3dml", 36 "3g2" : "video/3gpp2", 37 "3gp" : "video/3gpp", 38 "a" : "application/octet-stream", 39 "aab" : "application/x-authorware-bin", 40 "aac" : "audio/x-aac", 41 "aam" : "application/x-authorware-map", 42 "aas" : "application/x-authorware-seg", 43 "abw" : "application/x-abiword", 44 "acc" : "application/vnd.americandynamics.acc", 45 "ace" : "application/x-ace-compressed", 46 "acu" : "application/vnd.acucobol", 47 "acutc" : "application/vnd.acucorp", 48 "adp" : "audio/adpcm", 49 "aep" : "application/vnd.audiograph", 50 "afm" : "application/x-font-type1", 51 "afp" : "application/vnd.ibm.modcap", 52 "ai" : "application/postscript", 53 "aif" : "audio/x-aiff", 54 "aifc" : "audio/x-aiff", 55 "aiff" : "audio/x-aiff", 56 "air" : "application/vnd.adobe.air-application-installer-package+zip", 57 "ami" : "application/vnd.amiga.ami", 58 "apk" : "application/vnd.android.package-archive", 59 "application" : "application/x-ms-application", 60 "apr" : "application/vnd.lotus-approach", 61 "asc" : "application/pgp-signature", 62 "asf" : "video/x-ms-asf", 63 "asm" : "text/x-asm", 64 "aso" : "application/vnd.accpac.simply.aso", 65 "asx" : "video/x-ms-asf", 66 "atc" : "application/vnd.acucorp", 67 "atom" : "application/atom+xml", 68 "atomcat" : "application/atomcat+xml", 69 "atomsvc" : "application/atomsvc+xml", 70 "atx" : "application/vnd.antix.game-component", 71 "au" : "audio/basic", 72 "avi" : "video/x-msvideo", 73 "aw" : "application/applixware", 74 "azf" : "application/vnd.airzip.filesecure.azf", 75 "azs" : "application/vnd.airzip.filesecure.azs", 76 "azw" : "application/vnd.amazon.ebook", 77 "bat" : "application/x-msdownload", 78 "bcpio" : "application/x-bcpio", 79 "bdf" : "application/x-font-bdf", 80 "bdm" : "application/vnd.syncml.dm+wbxml", 81 "bh2" : "application/vnd.fujitsu.oasysprs", 82 "bin" : "application/octet-stream", 83 "bmi" : "application/vnd.bmi", 84 "bmp" : "image/bmp", 85 "book" : "application/vnd.framemaker", 86 "box" : "application/vnd.previewsystems.box", 87 "boz" : "application/x-bzip2", 88 "bpk" : "application/octet-stream", 89 "btif" : "image/prs.btif", 90 "bz" : "application/x-bzip", 91 "bz2" : "application/x-bzip2", 92 "c" : "text/x-c", 93 "c4d" : "application/vnd.clonk.c4group", 94 "c4f" : "application/vnd.clonk.c4group", 95 "c4g" : "application/vnd.clonk.c4group", 96 "c4p" : "application/vnd.clonk.c4group", 97 "c4u" : "application/vnd.clonk.c4group", 98 "cab" : "application/vnd.ms-cab-compressed", 99 "car" : "application/vnd.curl.car", 100 "cat" : "application/vnd.ms-pki.seccat", 101 "cc" : "text/x-c", 102 "cct" : "application/x-director", 103 "ccxml" : "application/ccxml+xml", 104 "cdbcmsg" : "application/vnd.contact.cmsg", 105 "cdf" : "application/x-netcdf", 106 "cdkey" : "application/vnd.mediastation.cdkey", 107 "cdx" : "chemical/x-cdx", 108 "cdxml" : "application/vnd.chemdraw+xml", 109 "cdy" : "application/vnd.cinderella", 110 "cer" : "application/pkix-cert", 111 "cgm" : "image/cgm", 112 "chat" : "application/x-chat", 113 "chm" : "application/vnd.ms-htmlhelp", 114 "chrt" : "application/vnd.kde.kchart", 115 "cif" : "chemical/x-cif", 116 "cii" : "application/vnd.anser-web-certificate-issue-initiation", 117 "cil" : "application/vnd.ms-artgalry", 118 "cla" : "application/vnd.claymore", 119 "class" : "application/java-vm", 120 "clkk" : "application/vnd.crick.clicker.keyboard", 121 "clkp" : "application/vnd.crick.clicker.palette", 122 "clkt" : "application/vnd.crick.clicker.template", 123 "clkw" : "application/vnd.crick.clicker.wordbank", 124 "clkx" : "application/vnd.crick.clicker", 125 "clp" : "application/x-msclip", 126 "cmc" : "application/vnd.cosmocaller", 127 "cmdf" : "chemical/x-cmdf", 128 "cml" : "chemical/x-cml", 129 "cmp" : "application/vnd.yellowriver-custom-menu", 130 "cmx" : "image/x-cmx", 131 "cod" : "application/vnd.rim.cod", 132 "com" : "application/x-msdownload", 133 "conf" : "text/plain", 134 "cpio" : "application/x-cpio", 135 "cpp" : "text/x-c", 136 "cpt" : "application/mac-compactpro", 137 "crd" : "application/x-mscardfile", 138 "crl" : "application/pkix-crl", 139 "crt" : "application/x-x509-ca-cert", 140 "csh" : "application/x-csh", 141 "csml" : "chemical/x-csml", 142 "csp" : "application/vnd.commonspace", 143 "css" : "text/css", 144 "cst" : "application/x-director", 145 "csv" : "text/csv", 146 "cu" : "application/cu-seeme", 147 "curl" : "text/vnd.curl", 148 "cww" : "application/prs.cww", 149 "cxt" : "application/x-director", 150 "cxx" : "text/x-c", 151 "daf" : "application/vnd.mobius.daf", 152 "dataless" : "application/vnd.fdsn.seed", 153 "davmount" : "application/davmount+xml", 154 "dcr" : "application/x-director", 155 "dcurl" : "text/vnd.curl.dcurl", 156 "dd2" : "application/vnd.oma.dd2+xml", 157 "ddd" : "application/vnd.fujixerox.ddd", 158 "deb" : "application/x-debian-package", 159 "def" : "text/plain", 160 "deploy" : "application/octet-stream", 161 "der" : "application/x-x509-ca-cert", 162 "dfac" : "application/vnd.dreamfactory", 163 "dic" : "text/x-c", 164 "diff" : "text/plain", 165 "dir" : "application/x-director", 166 "dis" : "application/vnd.mobius.dis", 167 "dist" : "application/octet-stream", 168 "distz" : "application/octet-stream", 169 "djv" : "image/vnd.djvu", 170 "djvu" : "image/vnd.djvu", 171 "dll" : "application/x-msdownload", 172 "dmg" : "application/octet-stream", 173 "dms" : "application/octet-stream", 174 "dna" : "application/vnd.dna", 175 "doc" : "application/msword", 176 "docm" : "application/vnd.ms-word.document.macroenabled.12", 177 "docx" : "application/vnd.openxmlformats-officedocument.wordprocessingml.document", 178 "dot" : "application/msword", 179 "dotm" : "application/vnd.ms-word.template.macroenabled.12", 180 "dotx" : "application/vnd.openxmlformats-officedocument.wordprocessingml.template", 181 "dp" : "application/vnd.osgi.dp", 182 "dpg" : "application/vnd.dpgraph", 183 "dsc" : "text/prs.lines.tag", 184 "dtb" : "application/x-dtbook+xml", 185 "dtd" : "application/xml-dtd", 186 "dts" : "audio/vnd.dts", 187 "dtshd" : "audio/vnd.dts.hd", 188 "dump" : "application/octet-stream", 189 "dvi" : "application/x-dvi", 190 "dwf" : "model/vnd.dwf", 191 "dwg" : "image/vnd.dwg", 192 "dxf" : "image/vnd.dxf", 193 "dxp" : "application/vnd.spotfire.dxp", 194 "dxr" : "application/x-director", 195 "ecelp4800" : "audio/vnd.nuera.ecelp4800", 196 "ecelp7470" : "audio/vnd.nuera.ecelp7470", 197 "ecelp9600" : "audio/vnd.nuera.ecelp9600", 198 "ecma" : "application/ecmascript", 199 "edm" : "application/vnd.novadigm.edm", 200 "edx" : "application/vnd.novadigm.edx", 201 "efif" : "application/vnd.picsel", 202 "ei6" : "application/vnd.pg.osasli", 203 "elc" : "application/octet-stream", 204 "eml" : "message/rfc822", 205 "emma" : "application/emma+xml", 206 "eol" : "audio/vnd.digital-winds", 207 "eot" : "application/vnd.ms-fontobject", 208 "eps" : "application/postscript", 209 "epub" : "application/epub+zip", 210 "es3" : "application/vnd.eszigno3+xml", 211 "esf" : "application/vnd.epson.esf", 212 "et3" : "application/vnd.eszigno3+xml", 213 "etx" : "text/x-setext", 214 "exe" : "application/x-msdownload", 215 "ext" : "application/vnd.novadigm.ext", 216 "ez" : "application/andrew-inset", 217 "ez2" : "application/vnd.ezpix-album", 218 "ez3" : "application/vnd.ezpix-package", 219 "f" : "text/x-fortran", 220 "f4v" : "video/x-f4v", 221 "f77" : "text/x-fortran", 222 "f90" : "text/x-fortran", 223 "fbs" : "image/vnd.fastbidsheet", 224 "fdf" : "application/vnd.fdf", 225 "fe_launch" : "application/vnd.denovo.fcselayout-link", 226 "fg5" : "application/vnd.fujitsu.oasysgp", 227 "fgd" : "application/x-director", 228 "fh" : "image/x-freehand", 229 "fh4" : "image/x-freehand", 230 "fh5" : "image/x-freehand", 231 "fh7" : "image/x-freehand", 232 "fhc" : "image/x-freehand", 233 "fig" : "application/x-xfig", 234 "fli" : "video/x-fli", 235 "flo" : "application/vnd.micrografx.flo", 236 "flv" : "video/x-flv", 237 "flw" : "application/vnd.kde.kivio", 238 "flx" : "text/vnd.fmi.flexstor", 239 "fly" : "text/vnd.fly", 240 "fm" : "application/vnd.framemaker", 241 "fnc" : "application/vnd.frogans.fnc", 242 "for" : "text/x-fortran", 243 "fpx" : "image/vnd.fpx", 244 "frame" : "application/vnd.framemaker", 245 "fsc" : "application/vnd.fsc.weblaunch", 246 "fst" : "image/vnd.fst", 247 "ftc" : "application/vnd.fluxtime.clip", 248 "fti" : "application/vnd.anser-web-funds-transfer-initiation", 249 "fvt" : "video/vnd.fvt", 250 "fzs" : "application/vnd.fuzzysheet", 251 "g3" : "image/g3fax", 252 "gac" : "application/vnd.groove-account", 253 "gdl" : "model/vnd.gdl", 254 "geo" : "application/vnd.dynageo", 255 "gex" : "application/vnd.geometry-explorer", 256 "ggb" : "application/vnd.geogebra.file", 257 "ggt" : "application/vnd.geogebra.tool", 258 "ghf" : "application/vnd.groove-help", 259 "gif" : "image/gif", 260 "gim" : "application/vnd.groove-identity-message", 261 "gmx" : "application/vnd.gmx", 262 "gnumeric" : "application/x-gnumeric", 263 "gph" : "application/vnd.flographit", 264 "gqf" : "application/vnd.grafeq", 265 "gqs" : "application/vnd.grafeq", 266 "gram" : "application/srgs", 267 "gre" : "application/vnd.geometry-explorer", 268 "grv" : "application/vnd.groove-injector", 269 "grxml" : "application/srgs+xml", 270 "gsf" : "application/x-font-ghostscript", 271 "gtar" : "application/x-gtar", 272 "gtm" : "application/vnd.groove-tool-message", 273 "gtw" : "model/vnd.gtw", 274 "gv" : "text/vnd.graphviz", 275 "gz" : "application/x-gzip", 276 "h" : "text/x-c", 277 "h261" : "video/h261", 278 "h263" : "video/h263", 279 "h264" : "video/h264", 280 "hbci" : "application/vnd.hbci", 281 "hdf" : "application/x-hdf", 282 "hh" : "text/x-c", 283 "hlp" : "application/winhlp", 284 "hpgl" : "application/vnd.hp-hpgl", 285 "hpid" : "application/vnd.hp-hpid", 286 "hps" : "application/vnd.hp-hps", 287 "hqx" : "application/mac-binhex40", 288 "htke" : "application/vnd.kenameaapp", 289 "htm" : "text/html", 290 "html" : "text/html", 291 "hvd" : "application/vnd.yamaha.hv-dic", 292 "hvp" : "application/vnd.yamaha.hv-voice", 293 "hvs" : "application/vnd.yamaha.hv-script", 294 "icc" : "application/vnd.iccprofile", 295 "ice" : "x-conference/x-cooltalk", 296 "icm" : "application/vnd.iccprofile", 297 "ico" : "image/x-icon", 298 "ics" : "text/calendar", 299 "ief" : "image/ief", 300 "ifb" : "text/calendar", 301 "ifm" : "application/vnd.shana.informed.formdata", 302 "iges" : "model/iges", 303 "igl" : "application/vnd.igloader", 304 "igs" : "model/iges", 305 "igx" : "application/vnd.micrografx.igx", 306 "iif" : "application/vnd.shana.informed.interchange", 307 "imp" : "application/vnd.accpac.simply.imp", 308 "ims" : "application/vnd.ms-ims", 309 "in" : "text/plain", 310 "ipk" : "application/vnd.shana.informed.package", 311 "irm" : "application/vnd.ibm.rights-management", 312 "irp" : "application/vnd.irepository.package+xml", 313 "iso" : "application/octet-stream", 314 "itp" : "application/vnd.shana.informed.formtemplate", 315 "ivp" : "application/vnd.immervision-ivp", 316 "ivu" : "application/vnd.immervision-ivu", 317 "jad" : "text/vnd.sun.j2me.app-descriptor", 318 "jam" : "application/vnd.jam", 319 "jar" : "application/java-archive", 320 "java" : "text/x-java-source", 321 "jisp" : "application/vnd.jisp", 322 "jlt" : "application/vnd.hp-jlyt", 323 "jnlp" : "application/x-java-jnlp-file", 324 "joda" : "application/vnd.joost.joda-archive", 325 "jpe" : "image/jpeg", 326 "jpeg" : "image/jpeg", 327 "jpg" : "image/jpeg", 328 "jpgm" : "video/jpm", 329 "jpgv" : "video/jpeg", 330 "jpm" : "video/jpm", 331 "js" : "application/javascript", 332 "json" : "application/json", 333 "kar" : "audio/midi", 334 "karbon" : "application/vnd.kde.karbon", 335 "kfo" : "application/vnd.kde.kformula", 336 "kia" : "application/vnd.kidspiration", 337 "kil" : "application/x-killustrator", 338 "kml" : "application/vnd.google-earth.kml+xml", 339 "kmz" : "application/vnd.google-earth.kmz", 340 "kne" : "application/vnd.kinar", 341 "knp" : "application/vnd.kinar", 342 "kon" : "application/vnd.kde.kontour", 343 "kpr" : "application/vnd.kde.kpresenter", 344 "kpt" : "application/vnd.kde.kpresenter", 345 "ksh" : "text/plain", 346 "ksp" : "application/vnd.kde.kspread", 347 "ktr" : "application/vnd.kahootz", 348 "ktz" : "application/vnd.kahootz", 349 "kwd" : "application/vnd.kde.kword", 350 "kwt" : "application/vnd.kde.kword", 351 "latex" : "application/x-latex", 352 "lbd" : "application/vnd.llamagraphics.life-balance.desktop", 353 "lbe" : "application/vnd.llamagraphics.life-balance.exchange+xml", 354 "les" : "application/vnd.hhe.lesson-player", 355 "lha" : "application/octet-stream", 356 "link66" : "application/vnd.route66.link66+xml", 357 "list" : "text/plain", 358 "list3820" : "application/vnd.ibm.modcap", 359 "listafp" : "application/vnd.ibm.modcap", 360 "log" : "text/plain", 361 "lostxml" : "application/lost+xml", 362 "lrf" : "application/octet-stream", 363 "lrm" : "application/vnd.ms-lrm", 364 "ltf" : "application/vnd.frogans.ltf", 365 "lvp" : "audio/vnd.lucent.voice", 366 "lwp" : "application/vnd.lotus-wordpro", 367 "lzh" : "application/octet-stream", 368 "m13" : "application/x-msmediaview", 369 "m14" : "application/x-msmediaview", 370 "m1v" : "video/mpeg", 371 "m2a" : "audio/mpeg", 372 "m2v" : "video/mpeg", 373 "m3a" : "audio/mpeg", 374 "m3u" : "audio/x-mpegurl", 375 "m4u" : "video/vnd.mpegurl", 376 "m4v" : "video/x-m4v", 377 "ma" : "application/mathematica", 378 "mag" : "application/vnd.ecowin.chart", 379 "maker" : "application/vnd.framemaker", 380 "man" : "text/troff", 381 "mathml" : "application/mathml+xml", 382 "mb" : "application/mathematica", 383 "mbk" : "application/vnd.mobius.mbk", 384 "mbox" : "application/mbox", 385 "mc1" : "application/vnd.medcalcdata", 386 "mcd" : "application/vnd.mcd", 387 "mcurl" : "text/vnd.curl.mcurl", 388 "mdb" : "application/x-msaccess", 389 "mdi" : "image/vnd.ms-modi", 390 "me" : "text/troff", 391 "mesh" : "model/mesh", 392 "mfm" : "application/vnd.mfmp", 393 "mgz" : "application/vnd.proteus.magazine", 394 "mht" : "message/rfc822", 395 "mhtml" : "message/rfc822", 396 "mid" : "audio/midi", 397 "midi" : "audio/midi", 398 "mif" : "application/vnd.mif", 399 "mime" : "message/rfc822", 400 "mj2" : "video/mj2", 401 "mjp2" : "video/mj2", 402 "mlp" : "application/vnd.dolby.mlp", 403 "mmd" : "application/vnd.chipnuts.karaoke-mmd", 404 "mmf" : "application/vnd.smaf", 405 "mmr" : "image/vnd.fujixerox.edmics-mmr", 406 "mny" : "application/x-msmoney", 407 "mobi" : "application/x-mobipocket-ebook", 408 "mov" : "video/quicktime", 409 "movie" : "video/x-sgi-movie", 410 "mp2" : "audio/mpeg", 411 "mp2a" : "audio/mpeg", 412 "mp3" : "audio/mpeg", 413 "mp4" : "video/mp4", 414 "mp4a" : "audio/mp4", 415 "mp4s" : "application/mp4", 416 "mp4v" : "video/mp4", 417 "mpa" : "video/mpeg", 418 "mpc" : "application/vnd.mophun.certificate", 419 "mpe" : "video/mpeg", 420 "mpeg" : "video/mpeg", 421 "mpg" : "video/mpeg", 422 "mpg4" : "video/mp4", 423 "mpga" : "audio/mpeg", 424 "mpkg" : "application/vnd.apple.installer+xml", 425 "mpm" : "application/vnd.blueice.multipass", 426 "mpn" : "application/vnd.mophun.application", 427 "mpp" : "application/vnd.ms-project", 428 "mpt" : "application/vnd.ms-project", 429 "mpy" : "application/vnd.ibm.minipay", 430 "mqy" : "application/vnd.mobius.mqy", 431 "mrc" : "application/marc", 432 "ms" : "text/troff", 433 "mscml" : "application/mediaservercontrol+xml", 434 "mseed" : "application/vnd.fdsn.mseed", 435 "mseq" : "application/vnd.mseq", 436 "msf" : "application/vnd.epson.msf", 437 "msh" : "model/mesh", 438 "msi" : "application/x-msdownload", 439 "msl" : "application/vnd.mobius.msl", 440 "msty" : "application/vnd.muvee.style", 441 "mts" : "model/vnd.mts", 442 "mus" : "application/vnd.musician", 443 "musicxml" : "application/vnd.recordare.musicxml+xml", 444 "mvb" : "application/x-msmediaview", 445 "mwf" : "application/vnd.mfer", 446 "mxf" : "application/mxf", 447 "mxl" : "application/vnd.recordare.musicxml", 448 "mxml" : "application/xv+xml", 449 "mxs" : "application/vnd.triscape.mxs", 450 "mxu" : "video/vnd.mpegurl", 451 "n-gage" : "application/vnd.nokia.n-gage.symbian.install", 452 "nb" : "application/mathematica", 453 "nc" : "application/x-netcdf", 454 "ncx" : "application/x-dtbncx+xml", 455 "ngdat" : "application/vnd.nokia.n-gage.data", 456 "nlu" : "application/vnd.neurolanguage.nlu", 457 "nml" : "application/vnd.enliven", 458 "nnd" : "application/vnd.noblenet-directory", 459 "nns" : "application/vnd.noblenet-sealer", 460 "nnw" : "application/vnd.noblenet-web", 461 "npx" : "image/vnd.net-fpx", 462 "nsf" : "application/vnd.lotus-notes", 463 "nws" : "message/rfc822", 464 "o" : "application/octet-stream", 465 "oa2" : "application/vnd.fujitsu.oasys2", 466 "oa3" : "application/vnd.fujitsu.oasys3", 467 "oas" : "application/vnd.fujitsu.oasys", 468 "obd" : "application/x-msbinder", 469 "obj" : "application/octet-stream", 470 "oda" : "application/oda", 471 "odb" : "application/vnd.oasis.opendocument.database", 472 "odc" : "application/vnd.oasis.opendocument.chart", 473 "odf" : "application/vnd.oasis.opendocument.formula", 474 "odft" : "application/vnd.oasis.opendocument.formula-template", 475 "odg" : "application/vnd.oasis.opendocument.graphics", 476 "odi" : "application/vnd.oasis.opendocument.image", 477 "odp" : "application/vnd.oasis.opendocument.presentation", 478 "ods" : "application/vnd.oasis.opendocument.spreadsheet", 479 "odt" : "application/vnd.oasis.opendocument.text", 480 "oga" : "audio/ogg", 481 "ogg" : "audio/ogg", 482 "ogv" : "video/ogg", 483 "ogx" : "application/ogg", 484 "onepkg" : "application/onenote", 485 "onetmp" : "application/onenote", 486 "onetoc" : "application/onenote", 487 "onetoc2" : "application/onenote", 488 "opf" : "application/oebps-package+xml", 489 "oprc" : "application/vnd.palm", 490 "org" : "application/vnd.lotus-organizer", 491 "osf" : "application/vnd.yamaha.openscoreformat", 492 "osfpvg" : "application/vnd.yamaha.openscoreformat.osfpvg+xml", 493 "otc" : "application/vnd.oasis.opendocument.chart-template", 494 "otf" : "application/x-font-otf", 495 "otg" : "application/vnd.oasis.opendocument.graphics-template", 496 "oth" : "application/vnd.oasis.opendocument.text-web", 497 "oti" : "application/vnd.oasis.opendocument.image-template", 498 "otm" : "application/vnd.oasis.opendocument.text-master", 499 "otp" : "application/vnd.oasis.opendocument.presentation-template", 500 "ots" : "application/vnd.oasis.opendocument.spreadsheet-template", 501 "ott" : "application/vnd.oasis.opendocument.text-template", 502 "oxt" : "application/vnd.openofficeorg.extension", 503 "p" : "text/x-pascal", 504 "p10" : "application/pkcs10", 505 "p12" : "application/x-pkcs12", 506 "p7b" : "application/x-pkcs7-certificates", 507 "p7c" : "application/pkcs7-mime", 508 "p7m" : "application/pkcs7-mime", 509 "p7r" : "application/x-pkcs7-certreqresp", 510 "p7s" : "application/pkcs7-signature", 511 "pas" : "text/x-pascal", 512 "pbd" : "application/vnd.powerbuilder6", 513 "pbm" : "image/x-portable-bitmap", 514 "pcf" : "application/x-font-pcf", 515 "pcl" : "application/vnd.hp-pcl", 516 "pclxl" : "application/vnd.hp-pclxl", 517 "pct" : "image/x-pict", 518 "pcurl" : "application/vnd.curl.pcurl", 519 "pcx" : "image/x-pcx", 520 "pdb" : "application/vnd.palm", 521 "pdf" : "application/pdf", 522 "pfa" : "application/x-font-type1", 523 "pfb" : "application/x-font-type1", 524 "pfm" : "application/x-font-type1", 525 "pfr" : "application/font-tdpfr", 526 "pfx" : "application/x-pkcs12", 527 "pgm" : "image/x-portable-graymap", 528 "pgn" : "application/x-chess-pgn", 529 "pgp" : "application/pgp-encrypted", 530 "pic" : "image/x-pict", 531 "pkg" : "application/octet-stream", 532 "pki" : "application/pkixcmp", 533 "pkipath" : "application/pkix-pkipath", 534 "pl" : "text/plain", 535 "plb" : "application/vnd.3gpp.pic-bw-large", 536 "plc" : "application/vnd.mobius.plc", 537 "plf" : "application/vnd.pocketlearn", 538 "pls" : "application/pls+xml", 539 "pml" : "application/vnd.ctc-posml", 540 "png" : "image/png", 541 "pnm" : "image/x-portable-anymap", 542 "portpkg" : "application/vnd.macports.portpkg", 543 "pot" : "application/vnd.ms-powerpoint", 544 "potm" : "application/vnd.ms-powerpoint.template.macroenabled.12", 545 "potx" : "application/vnd.openxmlformats-officedocument.presentationml.template", 546 "ppa" : "application/vnd.ms-powerpoint", 547 "ppam" : "application/vnd.ms-powerpoint.addin.macroenabled.12", 548 "ppd" : "application/vnd.cups-ppd", 549 "ppm" : "image/x-portable-pixmap", 550 "pps" : "application/vnd.ms-powerpoint", 551 "ppsm" : "application/vnd.ms-powerpoint.slideshow.macroenabled.12", 552 "ppsx" : "application/vnd.openxmlformats-officedocument.presentationml.slideshow", 553 "ppt" : "application/vnd.ms-powerpoint", 554 "pptm" : "application/vnd.ms-powerpoint.presentation.macroenabled.12", 555 "pptx" : "application/vnd.openxmlformats-officedocument.presentationml.presentation", 556 "pqa" : "application/vnd.palm", 557 "prc" : "application/x-mobipocket-ebook", 558 "pre" : "application/vnd.lotus-freelance", 559 "prf" : "application/pics-rules", 560 "ps" : "application/postscript", 561 "psb" : "application/vnd.3gpp.pic-bw-small", 562 "psd" : "image/vnd.adobe.photoshop", 563 "psf" : "application/x-font-linux-psf", 564 "ptid" : "application/vnd.pvi.ptid1", 565 "pub" : "application/x-mspublisher", 566 "pvb" : "application/vnd.3gpp.pic-bw-var", 567 "pwn" : "application/vnd.3m.post-it-notes", 568 "pwz" : "application/vnd.ms-powerpoint", 569 "py" : "text/x-python", 570 "pya" : "audio/vnd.ms-playready.media.pya", 571 "pyc" : "application/x-python-code", 572 "pyo" : "application/x-python-code", 573 "pyv" : "video/vnd.ms-playready.media.pyv", 574 "qam" : "application/vnd.epson.quickanime", 575 "qbo" : "application/vnd.intu.qbo", 576 "qfx" : "application/vnd.intu.qfx", 577 "qps" : "application/vnd.publishare-delta-tree", 578 "qt" : "video/quicktime", 579 "qwd" : "application/vnd.quark.quarkxpress", 580 "qwt" : "application/vnd.quark.quarkxpress", 581 "qxb" : "application/vnd.quark.quarkxpress", 582 "qxd" : "application/vnd.quark.quarkxpress", 583 "qxl" : "application/vnd.quark.quarkxpress", 584 "qxt" : "application/vnd.quark.quarkxpress", 585 "ra" : "audio/x-pn-realaudio", 586 "ram" : "audio/x-pn-realaudio", 587 "rar" : "application/x-rar-compressed", 588 "ras" : "image/x-cmu-raster", 589 "rcprofile" : "application/vnd.ipunplugged.rcprofile", 590 "rdf" : "application/rdf+xml", 591 "rdz" : "application/vnd.data-vision.rdz", 592 "rep" : "application/vnd.businessobjects", 593 "res" : "application/x-dtbresource+xml", 594 "rgb" : "image/x-rgb", 595 "rif" : "application/reginfo+xml", 596 "rl" : "application/resource-lists+xml", 597 "rlc" : "image/vnd.fujixerox.edmics-rlc", 598 "rld" : "application/resource-lists-diff+xml", 599 "rm" : "application/vnd.rn-realmedia", 600 "rmi" : "audio/midi", 601 "rmp" : "audio/x-pn-realaudio-plugin", 602 "rms" : "application/vnd.jcp.javame.midlet-rms", 603 "rnc" : "application/relax-ng-compact-syntax", 604 "roff" : "text/troff", 605 "rpm" : "application/x-rpm", 606 "rpss" : "application/vnd.nokia.radio-presets", 607 "rpst" : "application/vnd.nokia.radio-preset", 608 "rq" : "application/sparql-query", 609 "rs" : "application/rls-services+xml", 610 "rsd" : "application/rsd+xml", 611 "rss" : "application/rss+xml", 612 "rtf" : "application/rtf", 613 "rtx" : "text/richtext", 614 "s" : "text/x-asm", 615 "saf" : "application/vnd.yamaha.smaf-audio", 616 "sbml" : "application/sbml+xml", 617 "sc" : "application/vnd.ibm.secure-container", 618 "scd" : "application/x-msschedule", 619 "scm" : "application/vnd.lotus-screencam", 620 "scq" : "application/scvp-cv-request", 621 "scs" : "application/scvp-cv-response", 622 "scurl" : "text/vnd.curl.scurl", 623 "sda" : "application/vnd.stardivision.draw", 624 "sdc" : "application/vnd.stardivision.calc", 625 "sdd" : "application/vnd.stardivision.impress", 626 "sdkd" : "application/vnd.solent.sdkm+xml", 627 "sdkm" : "application/vnd.solent.sdkm+xml", 628 "sdp" : "application/sdp", 629 "sdw" : "application/vnd.stardivision.writer", 630 "see" : "application/vnd.seemail", 631 "seed" : "application/vnd.fdsn.seed", 632 "sema" : "application/vnd.sema", 633 "semd" : "application/vnd.semd", 634 "semf" : "application/vnd.semf", 635 "ser" : "application/java-serialized-object", 636 "setpay" : "application/set-payment-initiation", 637 "setreg" : "application/set-registration-initiation", 638 "sfd-hdstx" : "application/vnd.hydrostatix.sof-data", 639 "sfs" : "application/vnd.spotfire.sfs", 640 "sgl" : "application/vnd.stardivision.writer-global", 641 "sgm" : "text/sgml", 642 "sgml" : "text/sgml", 643 "sh" : "application/x-sh", 644 "shar" : "application/x-shar", 645 "shf" : "application/shf+xml", 646 "si" : "text/vnd.wap.si", 647 "sic" : "application/vnd.wap.sic", 648 "sig" : "application/pgp-signature", 649 "silo" : "model/mesh", 650 "sis" : "application/vnd.symbian.install", 651 "sisx" : "application/vnd.symbian.install", 652 "sit" : "application/x-stuffit", 653 "sitx" : "application/x-stuffitx", 654 "skd" : "application/vnd.koan", 655 "skm" : "application/vnd.koan", 656 "skp" : "application/vnd.koan", 657 "skt" : "application/vnd.koan", 658 "sl" : "text/vnd.wap.sl", 659 "slc" : "application/vnd.wap.slc", 660 "sldm" : "application/vnd.ms-powerpoint.slide.macroenabled.12", 661 "sldx" : "application/vnd.openxmlformats-officedocument.presentationml.slide", 662 "slt" : "application/vnd.epson.salt", 663 "smf" : "application/vnd.stardivision.math", 664 "smi" : "application/smil+xml", 665 "smil" : "application/smil+xml", 666 "snd" : "audio/basic", 667 "snf" : "application/x-font-snf", 668 "so" : "application/octet-stream", 669 "spc" : "application/x-pkcs7-certificates", 670 "spf" : "application/vnd.yamaha.smaf-phrase", 671 "spl" : "application/x-futuresplash", 672 "spot" : "text/vnd.in3d.spot", 673 "spp" : "application/scvp-vp-response", 674 "spq" : "application/scvp-vp-request", 675 "spx" : "audio/ogg", 676 "src" : "application/x-wais-source", 677 "srx" : "application/sparql-results+xml", 678 "sse" : "application/vnd.kodak-descriptor", 679 "ssf" : "application/vnd.epson.ssf", 680 "ssml" : "application/ssml+xml", 681 "stc" : "application/vnd.sun.xml.calc.template", 682 "std" : "application/vnd.sun.xml.draw.template", 683 "stf" : "application/vnd.wt.stf", 684 "sti" : "application/vnd.sun.xml.impress.template", 685 "stk" : "application/hyperstudio", 686 "stl" : "application/vnd.ms-pki.stl", 687 "str" : "application/vnd.pg.format", 688 "stw" : "application/vnd.sun.xml.writer.template", 689 "sus" : "application/vnd.sus-calendar", 690 "susp" : "application/vnd.sus-calendar", 691 "sv4cpio" : "application/x-sv4cpio", 692 "sv4crc" : "application/x-sv4crc", 693 "svd" : "application/vnd.svd", 694 "svg" : "image/svg+xml", 695 "svgz" : "image/svg+xml", 696 "swa" : "application/x-director", 697 "swf" : "application/x-shockwave-flash", 698 "swi" : "application/vnd.arastra.swi", 699 "sxc" : "application/vnd.sun.xml.calc", 700 "sxd" : "application/vnd.sun.xml.draw", 701 "sxg" : "application/vnd.sun.xml.writer.global", 702 "sxi" : "application/vnd.sun.xml.impress", 703 "sxm" : "application/vnd.sun.xml.math", 704 "sxw" : "application/vnd.sun.xml.writer", 705 "t" : "text/troff", 706 "tao" : "application/vnd.tao.intent-module-archive", 707 "tar" : "application/x-tar", 708 "tcap" : "application/vnd.3gpp2.tcap", 709 "tcl" : "application/x-tcl", 710 "teacher" : "application/vnd.smart.teacher", 711 "tex" : "application/x-tex", 712 "texi" : "application/x-texinfo", 713 "texinfo" : "application/x-texinfo", 714 "text" : "text/plain", 715 "tfm" : "application/x-tex-tfm", 716 "tgz" : "application/x-gzip", 717 "tif" : "image/tiff", 718 "tiff" : "image/tiff", 719 "tmo" : "application/vnd.tmobile-livetv", 720 "torrent" : "application/x-bittorrent", 721 "tpl" : "application/vnd.groove-tool-template", 722 "tpt" : "application/vnd.trid.tpt", 723 "tr" : "text/troff", 724 "tra" : "application/vnd.trueapp", 725 "trm" : "application/x-msterminal", 726 "tsv" : "text/tab-separated-values", 727 "ttc" : "application/x-font-ttf", 728 "ttf" : "application/x-font-ttf", 729 "twd" : "application/vnd.simtech-mindmapper", 730 "twds" : "application/vnd.simtech-mindmapper", 731 "txd" : "application/vnd.genomatix.tuxedo", 732 "txf" : "application/vnd.mobius.txf", 733 "txt" : "text/plain", 734 "u32" : "application/x-authorware-bin", 735 "udeb" : "application/x-debian-package", 736 "ufd" : "application/vnd.ufdl", 737 "ufdl" : "application/vnd.ufdl", 738 "umj" : "application/vnd.umajin", 739 "unityweb" : "application/vnd.unity", 740 "uoml" : "application/vnd.uoml+xml", 741 "uri" : "text/uri-list", 742 "uris" : "text/uri-list", 743 "urls" : "text/uri-list", 744 "ustar" : "application/x-ustar", 745 "utz" : "application/vnd.uiq.theme", 746 "uu" : "text/x-uuencode", 747 "vcd" : "application/x-cdlink", 748 "vcf" : "text/x-vcard", 749 "vcg" : "application/vnd.groove-vcard", 750 "vcs" : "text/x-vcalendar", 751 "vcx" : "application/vnd.vcx", 752 "vis" : "application/vnd.visionary", 753 "viv" : "video/vnd.vivo", 754 "vor" : "application/vnd.stardivision.writer", 755 "vox" : "application/x-authorware-bin", 756 "vrml" : "model/vrml", 757 "vsd" : "application/vnd.visio", 758 "vsf" : "application/vnd.vsf", 759 "vss" : "application/vnd.visio", 760 "vst" : "application/vnd.visio", 761 "vsw" : "application/vnd.visio", 762 "vtu" : "model/vnd.vtu", 763 "vxml" : "application/voicexml+xml", 764 "w3d" : "application/x-director", 765 "wad" : "application/x-doom", 766 "wav" : "audio/x-wav", 767 "wax" : "audio/x-ms-wax", 768 "wbmp" : "image/vnd.wap.wbmp", 769 "wbs" : "application/vnd.criticaltools.wbs+xml", 770 "wbxml" : "application/vnd.wap.wbxml", 771 "wcm" : "application/vnd.ms-works", 772 "wdb" : "application/vnd.ms-works", 773 "wiz" : "application/msword", 774 "wks" : "application/vnd.ms-works", 775 "wm" : "video/x-ms-wm", 776 "wma" : "audio/x-ms-wma", 777 "wmd" : "application/x-ms-wmd", 778 "wmf" : "application/x-msmetafile", 779 "wml" : "text/vnd.wap.wml", 780 "wmlc" : "application/vnd.wap.wmlc", 781 "wmls" : "text/vnd.wap.wmlscript", 782 "wmlsc" : "application/vnd.wap.wmlscriptc", 783 "wmv" : "video/x-ms-wmv", 784 "wmx" : "video/x-ms-wmx", 785 "wmz" : "application/x-ms-wmz", 786 "wpd" : "application/vnd.wordperfect", 787 "wpl" : "application/vnd.ms-wpl", 788 "wps" : "application/vnd.ms-works", 789 "wqd" : "application/vnd.wqd", 790 "wri" : "application/x-mswrite", 791 "wrl" : "model/vrml", 792 "wsdl" : "application/wsdl+xml", 793 "wspolicy" : "application/wspolicy+xml", 794 "wtb" : "application/vnd.webturbo", 795 "wvx" : "video/x-ms-wvx", 796 "x32" : "application/x-authorware-bin", 797 "x3d" : "application/vnd.hzn-3d-crossword", 798 "xap" : "application/x-silverlight-app", 799 "xar" : "application/vnd.xara", 800 "xbap" : "application/x-ms-xbap", 801 "xbd" : "application/vnd.fujixerox.docuworks.binder", 802 "xbm" : "image/x-xbitmap", 803 "xdm" : "application/vnd.syncml.dm+xml", 804 "xdp" : "application/vnd.adobe.xdp+xml", 805 "xdw" : "application/vnd.fujixerox.docuworks", 806 "xenc" : "application/xenc+xml", 807 "xer" : "application/patch-ops-error+xml", 808 "xfdf" : "application/vnd.adobe.xfdf", 809 "xfdl" : "application/vnd.xfdl", 810 "xht" : "application/xhtml+xml", 811 "xhtml" : "application/xhtml+xml", 812 "xhvml" : "application/xv+xml", 813 "xif" : "image/vnd.xiff", 814 "xla" : "application/vnd.ms-excel", 815 "xlam" : "application/vnd.ms-excel.addin.macroenabled.12", 816 "xlb" : "application/vnd.ms-excel", 817 "xlc" : "application/vnd.ms-excel", 818 "xlm" : "application/vnd.ms-excel", 819 "xls" : "application/vnd.ms-excel", 820 "xlsb" : "application/vnd.ms-excel.sheet.binary.macroenabled.12", 821 "xlsm" : "application/vnd.ms-excel.sheet.macroenabled.12", 822 "xlsx" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", 823 "xlt" : "application/vnd.ms-excel", 824 "xltm" : "application/vnd.ms-excel.template.macroenabled.12", 825 "xltx" : "application/vnd.openxmlformats-officedocument.spreadsheetml.template", 826 "xlw" : "application/vnd.ms-excel", 827 "xml" : "application/xml", 828 "xo" : "application/vnd.olpc-sugar", 829 "xop" : "application/xop+xml", 830 "xpdl" : "application/xml", 831 "xpi" : "application/x-xpinstall", 832 "xpm" : "image/x-xpixmap", 833 "xpr" : "application/vnd.is-xpr", 834 "xps" : "application/vnd.ms-xpsdocument", 835 "xpw" : "application/vnd.intercon.formnet", 836 "xpx" : "application/vnd.intercon.formnet", 837 "xsl" : "application/xml", 838 "xslt" : "application/xslt+xml", 839 "xsm" : "application/vnd.syncml+xml", 840 "xspf" : "application/xspf+xml", 841 "xul" : "application/vnd.mozilla.xul+xml", 842 "xvm" : "application/xv+xml", 843 "xvml" : "application/xv+xml", 844 "xwd" : "image/x-xwindowdump", 845 "xyz" : "chemical/x-xyz", 846 "zaz" : "application/vnd.zzazz.deck+xml", 847 "zip" : "application/zip", 848 "zir" : "application/vnd.zul", 849 "zirz" : "application/vnd.zul", 850 "zmm" : "application/vnd.handheld-entertainment+xml" 851 ]; 852 } 853 else 854 { 855 // Most common types. 856 857 auto mx = 858 [ 859 "bmp" : "image/bmp", 860 "bz" : "application/x-bzip", 861 "bz2" : "application/x-bzip2", 862 "chm" : "application/vnd.ms-htmlhelp", 863 "css" : "text/css", 864 "csv" : "text/csv", 865 "doc" : "application/msword", 866 "docx" : "application/vnd.openxmlformats-officedocument.wordprocessingml.document", 867 "dtd" : "application/xml-dtd", 868 "ecma" : "application/ecmascript", 869 "eml" : "message/rfc822", 870 "eps" : "application/postscript", 871 "epub" : "application/epub+zip", 872 "flv" : "video/x-flv", 873 "gif" : "image/gif", 874 "gz" : "application/x-gzip", 875 "h261" : "video/h261", 876 "h263" : "video/h263", 877 "h264" : "video/h264", 878 "htm" : "text/html", 879 "html" : "text/html", 880 "ico" : "image/x-icon", 881 "ics" : "text/calendar", 882 "ief" : "image/ief", 883 "ifb" : "text/calendar", 884 "jpe" : "image/jpeg", 885 "jpeg" : "image/jpeg", 886 "jpg" : "image/jpeg", 887 "jpgm" : "video/jpm", 888 "jpgv" : "video/jpeg", 889 "jpm" : "video/jpm", 890 "js" : "application/javascript", 891 "json" : "application/json", 892 "m1v" : "video/mpeg", 893 "m2a" : "audio/mpeg", 894 "m2v" : "video/mpeg", 895 "m3a" : "audio/mpeg", 896 "mathml" : "application/mathml+xml", 897 "mid" : "audio/midi", 898 "midi" : "audio/midi", 899 "mp2" : "audio/mpeg", 900 "mp2a" : "audio/mpeg", 901 "mp3" : "audio/mpeg", 902 "mp4" : "video/mp4", 903 "mp4a" : "audio/mp4", 904 "mp4s" : "application/mp4", 905 "mp4v" : "video/mp4", 906 "mpa" : "video/mpeg", 907 "mpe" : "video/mpeg", 908 "mpeg" : "video/mpeg", 909 "mpg" : "video/mpeg", 910 "mpg4" : "video/mp4", 911 "mpga" : "audio/mpeg", 912 "oga" : "audio/ogg", 913 "ogg" : "audio/ogg", 914 "ogv" : "video/ogg", 915 "ogx" : "application/ogg", 916 "pdf" : "application/pdf", 917 "png" : "image/png", 918 "pot" : "application/vnd.ms-powerpoint", 919 "potm" : "application/vnd.ms-powerpoint.template.macroenabled.12", 920 "potx" : "application/vnd.openxmlformats-officedocument.presentationml.template", 921 "ppa" : "application/vnd.ms-powerpoint", 922 "ppam" : "application/vnd.ms-powerpoint.addin.macroenabled.12", 923 "pps" : "application/vnd.ms-powerpoint", 924 "ppsm" : "application/vnd.ms-powerpoint.slideshow.macroenabled.12", 925 "ppsx" : "application/vnd.openxmlformats-officedocument.presentationml.slideshow", 926 "ppt" : "application/vnd.ms-powerpoint", 927 "pptm" : "application/vnd.ms-powerpoint.presentation.macroenabled.12", 928 "pptx" : "application/vnd.openxmlformats-officedocument.presentationml.presentation", 929 "ps" : "application/postscript", 930 "qt" : "video/quicktime", 931 "ra" : "audio/x-pn-realaudio", 932 "ram" : "audio/x-pn-realaudio", 933 "rar" : "application/x-rar-compressed", 934 "rtf" : "application/rtf", 935 "rtx" : "text/richtext", 936 "svg" : "image/svg+xml", 937 "svgz" : "image/svg+xml", 938 "tgz" : "application/x-gzip", 939 "tif" : "image/tiff", 940 "tiff" : "image/tiff", 941 "torrent" : "application/x-bittorrent", 942 "txt" : "text/plain", 943 "wmv" : "video/x-ms-wmv", 944 "wmx" : "video/x-ms-wmx", 945 "xbm" : "image/x-xbitmap", 946 "xht" : "application/xhtml+xml", 947 "xhtml" : "application/xhtml+xml", 948 "xla" : "application/vnd.ms-excel", 949 "xlam" : "application/vnd.ms-excel.addin.macroenabled.12", 950 "xlb" : "application/vnd.ms-excel", 951 "xlc" : "application/vnd.ms-excel", 952 "xlm" : "application/vnd.ms-excel", 953 "xls" : "application/vnd.ms-excel", 954 "xlsb" : "application/vnd.ms-excel.sheet.binary.macroenabled.12", 955 "xlsm" : "application/vnd.ms-excel.sheet.macroenabled.12", 956 "xlsx" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", 957 "xml" : "application/xml", 958 "xsl" : "application/xml", 959 "xslt" : "application/xslt+xml", 960 "zip" : "application/zip" 961 ]; 962 } 963 964 fileExtMimeTypes = assumeUnique(mx); 965 } 966 967 //---------------------------------------------------------------------------- 968 // Determine MIME type from a filename extension 969 970 string extMimeType(string ext) 971 { 972 ext = toLower(ext); 973 if (ext in fileExtMimeTypes) 974 return fileExtMimeTypes[ext]; 975 else 976 return "application/octet-stream"; 977 } 978 979 //---------------------------------------------------------------------------- 980 // Determine MIME type from a filename 981 982 string fileMimeType(string filename) 983 { 984 string ext = extension(filename); 985 if (ext.length == 0) 986 return "application/octet-stream"; 987 988 return extMimeType(ext[1..$]); 989 } 990 991 //---------------------------------------------------------------------------- 992 993 unittest 994 { 995 assert(fileMimeType("john.txt") == "text/plain"); 996 assert(fileMimeType("john.TXT") == "text/plain"); 997 assert(extMimeType("html") == "text/html"); 998 assert(extMimeType("HTML") == "text/html"); 999 assert(fileMimeType("noext") == "application/octet-stream"); 1000 assert(extMimeType("nonexistantextension") == "application/octet-stream"); 1001 assert(fileMimeType("file.nonexistantextension") == "application/octet-stream"); 1002 assert(extMimeType("") == "application/octet-stream"); 1003 assert(extMimeType(null) == "application/octet-stream"); 1004 }