File sharing server for small files

well_known_mime.rs 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. use std::fmt;
  2. use std::fmt::{Display, Formatter};
  3. use lazy_static::lazy_static;
  4. /// Mime type
  5. #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash)]
  6. pub enum Mime {
  7. /// Well-known mime
  8. WellKnown(usize),
  9. /// Custom mime
  10. Custom(String),
  11. }
  12. impl From<String> for Mime {
  13. fn from(s: String) -> Self {
  14. if let Some(index) = MIME_LOOKUP.get(&s.as_str()) {
  15. Mime::WellKnown(*index)
  16. } else {
  17. Mime::Custom(s)
  18. }
  19. }
  20. }
  21. impl<'a> From<&'a str> for Mime {
  22. fn from(s: &'a str) -> Self {
  23. if let Some(index) = MIME_LOOKUP.get(&s) {
  24. Mime::WellKnown(*index)
  25. } else {
  26. Mime::Custom(s.to_string())
  27. }
  28. }
  29. }
  30. impl Display for Mime {
  31. fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
  32. match self {
  33. Mime::WellKnown(n) => {
  34. if let Some(s) = WELL_KNOWN.get(*n) {
  35. f.write_str(s)
  36. } else {
  37. f.write_str("application/octet-stream")
  38. }
  39. }
  40. Mime::Custom(s) => f.write_str(s),
  41. }
  42. }
  43. }
  44. // The positions in this list must be kept stable - otherwise the persistence file may
  45. // deserialize to the wrong type.
  46. //
  47. // If a new type needs to be added, add it at the end.
  48. const WELL_KNOWN : &[&str] = &[
  49. "application/andrew-inset",
  50. "application/applixware",
  51. "application/atom+xml",
  52. "application/atomcat+xml",
  53. "application/atomsvc+xml",
  54. "application/ccxml+xml,",
  55. "application/cdmi-capability",
  56. "application/cdmi-container",
  57. "application/cdmi-domain",
  58. "application/cdmi-object",
  59. "application/cdmi-queue",
  60. "application/cu-seeme",
  61. "application/davmount+xml",
  62. "application/dssc+der",
  63. "application/dssc+xml",
  64. "application/ecmascript",
  65. "application/emma+xml",
  66. "application/epub+zip",
  67. "application/exi",
  68. "application/font-tdpfr",
  69. "application/hyperstudio",
  70. "application/ipfix",
  71. "application/java-archive",
  72. "application/java-serialized-object",
  73. "application/java-vm",
  74. "application/javascript",
  75. "application/json",
  76. "application/mac-binhex40",
  77. "application/mac-compactpro",
  78. "application/mads+xml",
  79. "application/marc",
  80. "application/marcxml+xml",
  81. "application/mathematica",
  82. "application/mathml+xml",
  83. "application/mbox",
  84. "application/mediaservercontrol+xml",
  85. "application/metalink4+xml",
  86. "application/mets+xml",
  87. "application/mods+xml",
  88. "application/mp21",
  89. "application/mp4",
  90. "application/msword",
  91. "application/mxf",
  92. "application/octet-stream",
  93. "application/oda",
  94. "application/oebps-package+xml",
  95. "application/ogg",
  96. "application/onenote",
  97. "application/patch-ops-error+xml",
  98. "application/pdf",
  99. "application/pgp-encrypted",
  100. "application/pgp-signature",
  101. "application/pics-rules",
  102. "application/pkcs10",
  103. "application/pkcs7-mime",
  104. "application/pkcs7-signature",
  105. "application/pkcs8",
  106. "application/pkix-attr-cert",
  107. "application/pkix-cert",
  108. "application/pkix-crl",
  109. "application/pkix-pkipath",
  110. "application/pkixcmp",
  111. "application/pls+xml",
  112. "application/postscript",
  113. "application/prs.cww",
  114. "application/pskc+xml",
  115. "application/rdf+xml",
  116. "application/reginfo+xml",
  117. "application/relax-ng-compact-syntax",
  118. "application/resource-lists+xml",
  119. "application/resource-lists-diff+xml",
  120. "application/rls-services+xml",
  121. "application/rsd+xml",
  122. "application/rss+xml",
  123. "application/rtf",
  124. "application/sbml+xml",
  125. "application/scvp-cv-request",
  126. "application/scvp-cv-response",
  127. "application/scvp-vp-request",
  128. "application/scvp-vp-response",
  129. "application/sdp",
  130. "application/set-payment-initiation",
  131. "application/set-registration-initiation",
  132. "application/shf+xml",
  133. "application/smil+xml",
  134. "application/sparql-query",
  135. "application/sparql-results+xml",
  136. "application/srgs",
  137. "application/srgs+xml",
  138. "application/sru+xml",
  139. "application/ssml+xml",
  140. "application/tei+xml",
  141. "application/thraud+xml",
  142. "application/timestamped-data",
  143. "application/vnd.3gpp.pic-bw-large",
  144. "application/vnd.3gpp.pic-bw-small",
  145. "application/vnd.3gpp.pic-bw-var",
  146. "application/vnd.3gpp2.tcap",
  147. "application/vnd.3m.post-it-notes",
  148. "application/vnd.accpac.simply.aso",
  149. "application/vnd.accpac.simply.imp",
  150. "application/vnd.acucobol",
  151. "application/vnd.acucorp",
  152. "application/vnd.adobe.air-application-installer-package+zip",
  153. "application/vnd.adobe.fxp",
  154. "application/vnd.adobe.xdp+xml",
  155. "application/vnd.adobe.xfdf",
  156. "application/vnd.ahead.space",
  157. "application/vnd.airzip.filesecure.azf",
  158. "application/vnd.airzip.filesecure.azs",
  159. "application/vnd.amazon.ebook",
  160. "application/vnd.americandynamics.acc",
  161. "application/vnd.amiga.ami",
  162. "application/vnd.android.package-archive",
  163. "application/vnd.anser-web-certificate-issue-initiation",
  164. "application/vnd.anser-web-funds-transfer-initiation",
  165. "application/vnd.antix.game-component",
  166. "application/vnd.apple.installer+xml",
  167. "application/vnd.apple.mpegurl",
  168. "application/vnd.aristanetworks.swi",
  169. "application/vnd.audiograph",
  170. "application/vnd.blueice.multipass",
  171. "application/vnd.bmi",
  172. "application/vnd.businessobjects",
  173. "application/vnd.chemdraw+xml",
  174. "application/vnd.chipnuts.karaoke-mmd",
  175. "application/vnd.cinderella",
  176. "application/vnd.claymore",
  177. "application/vnd.cloanto.rp9",
  178. "application/vnd.clonk.c4group",
  179. "application/vnd.cluetrust.cartomobile-config",
  180. "application/vnd.cluetrust.cartomobile-config-pkg",
  181. "application/vnd.commonspace",
  182. "application/vnd.contact.cmsg",
  183. "application/vnd.cosmocaller",
  184. "application/vnd.crick.clicker",
  185. "application/vnd.crick.clicker.keyboard",
  186. "application/vnd.crick.clicker.palette",
  187. "application/vnd.crick.clicker.template",
  188. "application/vnd.crick.clicker.wordbank",
  189. "application/vnd.criticaltools.wbs+xml",
  190. "application/vnd.ctc-posml",
  191. "application/vnd.cups-ppd",
  192. "application/vnd.curl.car",
  193. "application/vnd.curl.pcurl",
  194. "application/vnd.data-vision.rdz",
  195. "application/vnd.denovo.fcselayout-link",
  196. "application/vnd.dna",
  197. "application/vnd.dolby.mlp",
  198. "application/vnd.dpgraph",
  199. "application/vnd.dreamfactory",
  200. "application/vnd.dvb.ait",
  201. "application/vnd.dvb.service",
  202. "application/vnd.dynageo",
  203. "application/vnd.ecowin.chart",
  204. "application/vnd.enliven",
  205. "application/vnd.epson.esf",
  206. "application/vnd.epson.msf",
  207. "application/vnd.epson.quickanime",
  208. "application/vnd.epson.salt",
  209. "application/vnd.epson.ssf",
  210. "application/vnd.eszigno3+xml",
  211. "application/vnd.ezpix-album",
  212. "application/vnd.ezpix-package",
  213. "application/vnd.fdf",
  214. "application/vnd.fdsn.seed",
  215. "application/vnd.flographit",
  216. "application/vnd.fluxtime.clip",
  217. "application/vnd.framemaker",
  218. "application/vnd.frogans.fnc",
  219. "application/vnd.frogans.ltf",
  220. "application/vnd.fsc.weblaunch",
  221. "application/vnd.fujitsu.oasys",
  222. "application/vnd.fujitsu.oasys2",
  223. "application/vnd.fujitsu.oasys3",
  224. "application/vnd.fujitsu.oasysgp",
  225. "application/vnd.fujitsu.oasysprs",
  226. "application/vnd.fujixerox.ddd",
  227. "application/vnd.fujixerox.docuworks",
  228. "application/vnd.fujixerox.docuworks.binder",
  229. "application/vnd.fuzzysheet",
  230. "application/vnd.genomatix.tuxedo",
  231. "application/vnd.geogebra.file",
  232. "application/vnd.geogebra.tool",
  233. "application/vnd.geometry-explorer",
  234. "application/vnd.geonext",
  235. "application/vnd.geoplan",
  236. "application/vnd.geospace",
  237. "application/vnd.gmx",
  238. "application/vnd.google-earth.kml+xml",
  239. "application/vnd.google-earth.kmz",
  240. "application/vnd.grafeq",
  241. "application/vnd.groove-account",
  242. "application/vnd.groove-help",
  243. "application/vnd.groove-identity-message",
  244. "application/vnd.groove-injector",
  245. "application/vnd.groove-tool-message",
  246. "application/vnd.groove-tool-template",
  247. "application/vnd.groove-vcard",
  248. "application/vnd.hal+xml",
  249. "application/vnd.handheld-entertainment+xml",
  250. "application/vnd.hbci",
  251. "application/vnd.hhe.lesson-player",
  252. "application/vnd.hp-hpgl",
  253. "application/vnd.hp-hpid",
  254. "application/vnd.hp-hps",
  255. "application/vnd.hp-jlyt",
  256. "application/vnd.hp-pcl",
  257. "application/vnd.hp-pclxl",
  258. "application/vnd.hydrostatix.sof-data",
  259. "application/vnd.hzn-3d-crossword",
  260. "application/vnd.ibm.minipay",
  261. "application/vnd.ibm.modcap",
  262. "application/vnd.ibm.rights-management",
  263. "application/vnd.ibm.secure-container",
  264. "application/vnd.iccprofile",
  265. "application/vnd.igloader",
  266. "application/vnd.immervision-ivp",
  267. "application/vnd.immervision-ivu",
  268. "application/vnd.insors.igm",
  269. "application/vnd.intercon.formnet",
  270. "application/vnd.intergeo",
  271. "application/vnd.intu.qbo",
  272. "application/vnd.intu.qfx",
  273. "application/vnd.ipunplugged.rcprofile",
  274. "application/vnd.irepository.package+xml",
  275. "application/vnd.is-xpr",
  276. "application/vnd.isac.fcs",
  277. "application/vnd.jam",
  278. "application/vnd.jcp.javame.midlet-rms",
  279. "application/vnd.jisp",
  280. "application/vnd.joost.joda-archive",
  281. "application/vnd.kahootz",
  282. "application/vnd.kde.karbon",
  283. "application/vnd.kde.kchart",
  284. "application/vnd.kde.kformula",
  285. "application/vnd.kde.kivio",
  286. "application/vnd.kde.kontour",
  287. "application/vnd.kde.kpresenter",
  288. "application/vnd.kde.kspread",
  289. "application/vnd.kde.kword",
  290. "application/vnd.kenameaapp",
  291. "application/vnd.kidspiration",
  292. "application/vnd.kinar",
  293. "application/vnd.koan",
  294. "application/vnd.kodak-descriptor",
  295. "application/vnd.las.las+xml",
  296. "application/vnd.llamagraphics.life-balance.desktop",
  297. "application/vnd.llamagraphics.life-balance.exchange+xml",
  298. "application/vnd.lotus-1-2-3",
  299. "application/vnd.lotus-approach",
  300. "application/vnd.lotus-freelance",
  301. "application/vnd.lotus-notes",
  302. "application/vnd.lotus-organizer",
  303. "application/vnd.lotus-screencam",
  304. "application/vnd.lotus-wordpro",
  305. "application/vnd.macports.portpkg",
  306. "application/vnd.mcd",
  307. "application/vnd.medcalcdata",
  308. "application/vnd.mediastation.cdkey",
  309. "application/vnd.mfer",
  310. "application/vnd.mfmp",
  311. "application/vnd.micrografx.flo",
  312. "application/vnd.micrografx.igx",
  313. "application/vnd.mif",
  314. "application/vnd.mobius.daf",
  315. "application/vnd.mobius.dis",
  316. "application/vnd.mobius.mbk",
  317. "application/vnd.mobius.mqy",
  318. "application/vnd.mobius.msl",
  319. "application/vnd.mobius.plc",
  320. "application/vnd.mobius.txf",
  321. "application/vnd.mophun.application",
  322. "application/vnd.mophun.certificate",
  323. "application/vnd.mozilla.xul+xml",
  324. "application/vnd.ms-artgalry",
  325. "application/vnd.ms-cab-compressed",
  326. "application/vnd.ms-excel",
  327. "application/vnd.ms-excel.addin.macroenabled.12",
  328. "application/vnd.ms-excel.sheet.binary.macroenabled.12",
  329. "application/vnd.ms-excel.sheet.macroenabled.12",
  330. "application/vnd.ms-excel.template.macroenabled.12",
  331. "application/vnd.ms-fontobject",
  332. "application/vnd.ms-htmlhelp",
  333. "application/vnd.ms-ims",
  334. "application/vnd.ms-lrm",
  335. "application/vnd.ms-officetheme",
  336. "application/vnd.ms-pki.seccat",
  337. "application/vnd.ms-pki.stl",
  338. "application/vnd.ms-powerpoint",
  339. "application/vnd.ms-powerpoint.addin.macroenabled.12",
  340. "application/vnd.ms-powerpoint.presentation.macroenabled.12",
  341. "application/vnd.ms-powerpoint.slide.macroenabled.12",
  342. "application/vnd.ms-powerpoint.slideshow.macroenabled.12",
  343. "application/vnd.ms-powerpoint.template.macroenabled.12",
  344. "application/vnd.ms-project",
  345. "application/vnd.ms-word.document.macroenabled.12",
  346. "application/vnd.ms-word.template.macroenabled.12",
  347. "application/vnd.ms-works",
  348. "application/vnd.ms-wpl",
  349. "application/vnd.ms-xpsdocument",
  350. "application/vnd.mseq",
  351. "application/vnd.musician",
  352. "application/vnd.muvee.style",
  353. "application/vnd.neurolanguage.nlu",
  354. "application/vnd.noblenet-directory",
  355. "application/vnd.noblenet-sealer",
  356. "application/vnd.noblenet-web",
  357. "application/vnd.nokia.n-gage.data",
  358. "application/vnd.nokia.n-gage.symbian.install",
  359. "application/vnd.nokia.radio-preset",
  360. "application/vnd.nokia.radio-presets",
  361. "application/vnd.novadigm.edm",
  362. "application/vnd.novadigm.edx",
  363. "application/vnd.novadigm.ext",
  364. "application/vnd.oasis.opendocument.chart",
  365. "application/vnd.oasis.opendocument.chart-template",
  366. "application/vnd.oasis.opendocument.database",
  367. "application/vnd.oasis.opendocument.formula",
  368. "application/vnd.oasis.opendocument.formula-template",
  369. "application/vnd.oasis.opendocument.graphics",
  370. "application/vnd.oasis.opendocument.graphics-template",
  371. "application/vnd.oasis.opendocument.image",
  372. "application/vnd.oasis.opendocument.image-template",
  373. "application/vnd.oasis.opendocument.presentation",
  374. "application/vnd.oasis.opendocument.presentation-template",
  375. "application/vnd.oasis.opendocument.spreadsheet",
  376. "application/vnd.oasis.opendocument.spreadsheet-template",
  377. "application/vnd.oasis.opendocument.text",
  378. "application/vnd.oasis.opendocument.text-master",
  379. "application/vnd.oasis.opendocument.text-template",
  380. "application/vnd.oasis.opendocument.text-web",
  381. "application/vnd.olpc-sugar",
  382. "application/vnd.oma.dd2+xml",
  383. "application/vnd.openofficeorg.extension",
  384. "application/vnd.openxmlformats-officedocument.presentationml.presentation",
  385. "application/vnd.openxmlformats-officedocument.presentationml.slide",
  386. "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
  387. "application/vnd.openxmlformats-officedocument.presentationml.template",
  388. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
  389. "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
  390. "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  391. "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
  392. "application/vnd.osgeo.mapguide.package",
  393. "application/vnd.osgi.dp",
  394. "application/vnd.palm",
  395. "application/vnd.pawaafile",
  396. "application/vnd.pg.format",
  397. "application/vnd.pg.osasli",
  398. "application/vnd.picsel",
  399. "application/vnd.pmi.widget",
  400. "application/vnd.pocketlearn",
  401. "application/vnd.powerbuilder6",
  402. "application/vnd.previewsystems.box",
  403. "application/vnd.proteus.magazine",
  404. "application/vnd.publishare-delta-tree",
  405. "application/vnd.pvi.ptid1",
  406. "application/vnd.quark.quarkxpress",
  407. "application/vnd.realvnc.bed",
  408. "application/vnd.recordare.musicxml",
  409. "application/vnd.recordare.musicxml+xml",
  410. "application/vnd.rig.cryptonote",
  411. "application/vnd.rim.cod",
  412. "application/vnd.rn-realmedia",
  413. "application/vnd.route66.link66+xml",
  414. "application/vnd.sailingtracker.track",
  415. "application/vnd.seemail",
  416. "application/vnd.sema",
  417. "application/vnd.semd",
  418. "application/vnd.semf",
  419. "application/vnd.shana.informed.formdata",
  420. "application/vnd.shana.informed.formtemplate",
  421. "application/vnd.shana.informed.interchange",
  422. "application/vnd.shana.informed.package",
  423. "application/vnd.simtech-mindmapper",
  424. "application/vnd.smaf",
  425. "application/vnd.smart.teacher",
  426. "application/vnd.solent.sdkm+xml",
  427. "application/vnd.spotfire.dxp",
  428. "application/vnd.spotfire.sfs",
  429. "application/vnd.stardivision.calc",
  430. "application/vnd.stardivision.draw",
  431. "application/vnd.stardivision.impress",
  432. "application/vnd.stardivision.math",
  433. "application/vnd.stardivision.writer",
  434. "application/vnd.stardivision.writer-global",
  435. "application/vnd.stepmania.stepchart",
  436. "application/vnd.sun.xml.calc",
  437. "application/vnd.sun.xml.calc.template",
  438. "application/vnd.sun.xml.draw",
  439. "application/vnd.sun.xml.draw.template",
  440. "application/vnd.sun.xml.impress",
  441. "application/vnd.sun.xml.impress.template",
  442. "application/vnd.sun.xml.math",
  443. "application/vnd.sun.xml.writer",
  444. "application/vnd.sun.xml.writer.global",
  445. "application/vnd.sun.xml.writer.template",
  446. "application/vnd.sus-calendar",
  447. "application/vnd.svd",
  448. "application/vnd.symbian.install",
  449. "application/vnd.syncml+xml",
  450. "application/vnd.syncml.dm+wbxml",
  451. "application/vnd.syncml.dm+xml",
  452. "application/vnd.tao.intent-module-archive",
  453. "application/vnd.tmobile-livetv",
  454. "application/vnd.trid.tpt",
  455. "application/vnd.triscape.mxs",
  456. "application/vnd.trueapp",
  457. "application/vnd.ufdl",
  458. "application/vnd.uiq.theme",
  459. "application/vnd.umajin",
  460. "application/vnd.unity",
  461. "application/vnd.uoml+xml",
  462. "application/vnd.vcx",
  463. "application/vnd.visio",
  464. "application/vnd.visio2013",
  465. "application/vnd.visionary",
  466. "application/vnd.vsf",
  467. "application/vnd.wap.wbxml",
  468. "application/vnd.wap.wmlc",
  469. "application/vnd.wap.wmlscriptc",
  470. "application/vnd.webturbo",
  471. "application/vnd.wolfram.player",
  472. "application/vnd.wordperfect",
  473. "application/vnd.wqd",
  474. "application/vnd.wt.stf",
  475. "application/vnd.xara",
  476. "application/vnd.xfdl",
  477. "application/vnd.yamaha.hv-dic",
  478. "application/vnd.yamaha.hv-script",
  479. "application/vnd.yamaha.hv-voice",
  480. "application/vnd.yamaha.openscoreformat",
  481. "application/vnd.yamaha.openscoreformat.osfpvg+xml",
  482. "application/vnd.yamaha.smaf-audio",
  483. "application/vnd.yamaha.smaf-phrase",
  484. "application/vnd.yellowriver-custom-menu",
  485. "application/vnd.zul",
  486. "application/vnd.zzazz.deck+xml",
  487. "application/voicexml+xml",
  488. "application/widget",
  489. "application/winhlp",
  490. "application/wsdl+xml",
  491. "application/wspolicy+xml",
  492. "application/x-7z-compressed",
  493. "application/x-abiword",
  494. "application/x-ace-compressed",
  495. "application/x-apple-diskimage",
  496. "application/x-authorware-bin",
  497. "application/x-authorware-map",
  498. "application/x-authorware-seg",
  499. "application/x-bcpio",
  500. "application/x-bittorrent",
  501. "application/x-bzip",
  502. "application/x-bzip2",
  503. "application/x-cdlink",
  504. "application/x-chat",
  505. "application/x-chess-pgn",
  506. "application/x-cpio",
  507. "application/x-csh",
  508. "application/x-debian-package",
  509. "application/x-director",
  510. "application/x-doom",
  511. "application/x-dtbncx+xml",
  512. "application/x-dtbook+xml",
  513. "application/x-dtbresource+xml",
  514. "application/x-dvi",
  515. "application/x-font-bdf",
  516. "application/x-font-ghostscript",
  517. "application/x-font-linux-psf",
  518. "application/x-font-otf",
  519. "application/x-font-pcf",
  520. "application/x-font-snf",
  521. "application/x-font-ttf",
  522. "application/x-font-type1",
  523. "application/x-font-woff",
  524. "application/x-futuresplash",
  525. "application/x-gnumeric",
  526. "application/x-gtar",
  527. "application/x-hdf",
  528. "application/x-java-jnlp-file",
  529. "application/x-latex",
  530. "application/x-mobipocket-ebook",
  531. "application/x-ms-application",
  532. "application/x-ms-wmd",
  533. "application/x-ms-wmz",
  534. "application/x-ms-xbap",
  535. "application/x-msaccess",
  536. "application/x-msbinder",
  537. "application/x-mscardfile",
  538. "application/x-msclip",
  539. "application/x-msdownload",
  540. "application/x-msmediaview",
  541. "application/x-msmetafile",
  542. "application/x-msmoney",
  543. "application/x-mspublisher",
  544. "application/x-msschedule",
  545. "application/x-msterminal",
  546. "application/x-mswrite",
  547. "application/x-netcdf",
  548. "application/x-pkcs12",
  549. "application/x-pkcs7-certificates",
  550. "application/x-pkcs7-certreqresp",
  551. "application/x-rar-compressed",
  552. "application/x-sh",
  553. "application/x-shar",
  554. "application/x-shockwave-flash",
  555. "application/x-silverlight-app",
  556. "application/x-stuffit",
  557. "application/x-stuffitx",
  558. "application/x-sv4cpio",
  559. "application/x-sv4crc",
  560. "application/x-tar",
  561. "application/x-tcl",
  562. "application/x-tex",
  563. "application/x-tex-tfm",
  564. "application/x-texinfo",
  565. "application/x-ustar",
  566. "application/x-wais-source",
  567. "application/x-x509-ca-cert",
  568. "application/x-xfig",
  569. "application/x-xpinstall",
  570. "application/xcap-diff+xml",
  571. "application/xenc+xml",
  572. "application/xhtml+xml",
  573. "application/xml",
  574. "application/xml-dtd",
  575. "application/xop+xml",
  576. "application/xslt+xml",
  577. "application/xspf+xml",
  578. "application/xv+xml",
  579. "application/yang",
  580. "application/yin+xml",
  581. "application/zip",
  582. "audio/adpcm",
  583. "audio/basic",
  584. "audio/midi",
  585. "audio/mp4",
  586. "audio/mpeg",
  587. "audio/ogg",
  588. "audio/vnd.dece.audio",
  589. "audio/vnd.digital-winds",
  590. "audio/vnd.dra",
  591. "audio/vnd.dts",
  592. "audio/vnd.dts.hd",
  593. "audio/vnd.lucent.voice",
  594. "audio/vnd.ms-playready.media.pya",
  595. "audio/vnd.nuera.ecelp4800",
  596. "audio/vnd.nuera.ecelp7470",
  597. "audio/vnd.nuera.ecelp9600",
  598. "audio/vnd.rip",
  599. "audio/webm",
  600. "audio/x-aac",
  601. "audio/x-aiff",
  602. "audio/x-mpegurl",
  603. "audio/x-ms-wax",
  604. "audio/x-ms-wma",
  605. "audio/x-pn-realaudio",
  606. "audio/x-pn-realaudio-plugin",
  607. "audio/x-wav",
  608. "chemical/x-cdx",
  609. "chemical/x-cif",
  610. "chemical/x-cmdf",
  611. "chemical/x-cml",
  612. "chemical/x-csml",
  613. "chemical/x-xyz",
  614. "image/bmp",
  615. "image/cgm",
  616. "image/g3fax",
  617. "image/gif",
  618. "image/ief",
  619. "image/jpeg",
  620. "image/ktx",
  621. "image/pjpeg",
  622. "image/png",
  623. "image/prs.btif",
  624. "image/svg+xml",
  625. "image/tiff",
  626. "image/vnd.adobe.photoshop",
  627. "image/vnd.dece.graphic",
  628. "image/vnd.djvu",
  629. "image/vnd.dvb.subtitle",
  630. "image/vnd.dwg",
  631. "image/vnd.dxf",
  632. "image/vnd.fastbidsheet",
  633. "image/vnd.fpx",
  634. "image/vnd.fst",
  635. "image/vnd.fujixerox.edmics-mmr",
  636. "image/vnd.fujixerox.edmics-rlc",
  637. "image/vnd.ms-modi",
  638. "image/vnd.net-fpx",
  639. "image/vnd.wap.wbmp",
  640. "image/vnd.xiff",
  641. "image/webp",
  642. "image/x-citrix-jpeg",
  643. "image/x-citrix-png",
  644. "image/x-cmu-raster",
  645. "image/x-cmx",
  646. "image/x-freehand",
  647. "image/x-icon",
  648. "image/x-pcx",
  649. "image/x-pict",
  650. "image/x-png",
  651. "image/x-portable-anymap",
  652. "image/x-portable-bitmap",
  653. "image/x-portable-graymap",
  654. "image/x-portable-pixmap",
  655. "image/x-rgb",
  656. "image/x-xbitmap",
  657. "image/x-xpixmap",
  658. "image/x-xwindowdump",
  659. "message/rfc822",
  660. "model/iges",
  661. "model/mesh",
  662. "model/vnd.collada+xml",
  663. "model/vnd.dwf",
  664. "model/vnd.gdl",
  665. "model/vnd.gtw",
  666. "model/vnd.mts",
  667. "model/vnd.vtu",
  668. "model/vrml",
  669. "text/calendar",
  670. "text/css",
  671. "text/csv",
  672. "text/html",
  673. "text/n3",
  674. "text/plain",
  675. "text/plain-bas",
  676. "text/prs.lines.tag",
  677. "text/richtext",
  678. "text/sgml",
  679. "text/tab-separated-values",
  680. "text/troff",
  681. "text/turtle",
  682. "text/uri-list",
  683. "text/vnd.curl",
  684. "text/vnd.curl.dcurl",
  685. "text/vnd.curl.mcurl",
  686. "text/vnd.curl.scurl",
  687. "text/vnd.fly",
  688. "text/vnd.fmi.flexstor",
  689. "text/vnd.graphviz",
  690. "text/vnd.in3d.3dml",
  691. "text/vnd.in3d.spot",
  692. "text/vnd.sun.j2me.app-descriptor",
  693. "text/vnd.wap.wml",
  694. "text/vnd.wap.wmlscript",
  695. "text/x-asm",
  696. "text/x-c",
  697. "text/x-fortran",
  698. "text/x-java-source,java",
  699. "text/x-pascal",
  700. "text/x-setext",
  701. "text/x-uuencode",
  702. "text/x-vcalendar",
  703. "text/x-vcard",
  704. "text/yaml",
  705. "video/3gpp",
  706. "video/3gpp2",
  707. "video/h261",
  708. "video/h263",
  709. "video/h264",
  710. "video/jpeg",
  711. "video/jpm",
  712. "video/mj2",
  713. "video/mp4",
  714. "video/mpeg",
  715. "video/ogg",
  716. "video/quicktime",
  717. "video/vnd.dece.hd",
  718. "video/vnd.dece.mobile",
  719. "video/vnd.dece.pd",
  720. "video/vnd.dece.sd",
  721. "video/vnd.dece.video",
  722. "video/vnd.fvt",
  723. "video/vnd.mpegurl",
  724. "video/vnd.ms-playready.media.pyv",
  725. "video/vnd.uvvu.mp4",
  726. "video/vnd.vivo",
  727. "video/webm",
  728. "video/x-f4v",
  729. "video/x-fli",
  730. "video/x-flv",
  731. "video/x-m4v",
  732. "video/x-ms-asf",
  733. "video/x-ms-wm",
  734. "video/x-ms-wmv",
  735. "video/x-ms-wmx",
  736. "video/x-ms-wvx",
  737. "video/x-msvideo",
  738. "video/x-sgi-movie",
  739. "x-conference/x-cooltalk",
  740. // Extras
  741. "application/toml",
  742. "application/json5",
  743. ];
  744. use std::collections::HashMap;
  745. lazy_static!{
  746. static ref MIME_LOOKUP : HashMap<&'static str, usize> = {
  747. let mut map = HashMap::new();
  748. for (n, entry) in WELL_KNOWN.iter().enumerate() {
  749. map.insert(*entry, n);
  750. }
  751. map
  752. };
  753. }