@wooksjs/http-static 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,1397 @@
1
+ 'use strict';
2
+
3
+ var eventHttp = require('@wooksjs/event-http');
4
+ var fs = require('fs');
5
+ var path = require('path');
6
+
7
+ /******************************************************************************
8
+ Copyright (c) Microsoft Corporation.
9
+
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ PERFORMANCE OF THIS SOFTWARE.
20
+ ***************************************************************************** */
21
+
22
+ function __awaiter(thisArg, _arguments, P, generator) {
23
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
24
+ return new (P || (P = Promise))(function (resolve, reject) {
25
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
26
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
27
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
28
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
29
+ });
30
+ }
31
+
32
+ const extensions = {
33
+ '123': 'application/vnd.lotus-1-2-3',
34
+ 'ez': 'application/andrew-inset',
35
+ 'aw': 'application/applixware',
36
+ 'atom': 'application/atom+xml',
37
+ 'atomcat': 'application/atomcat+xml',
38
+ 'atomdeleted': 'application/atomdeleted+xml',
39
+ 'atomsvc': 'application/atomsvc+xml',
40
+ 'dwd': 'application/atsc-dwd+xml',
41
+ 'held': 'application/atsc-held+xml',
42
+ 'rsat': 'application/atsc-rsat+xml',
43
+ 'bdoc': 'application/x-bdoc',
44
+ 'xcs': 'application/calendar+xml',
45
+ 'ccxml': 'application/ccxml+xml',
46
+ 'cdfx': 'application/cdfx+xml',
47
+ 'cdmia': 'application/cdmi-capability',
48
+ 'cdmic': 'application/cdmi-container',
49
+ 'cdmid': 'application/cdmi-domain',
50
+ 'cdmio': 'application/cdmi-object',
51
+ 'cdmiq': 'application/cdmi-queue',
52
+ 'cpl': 'application/cpl+xml',
53
+ 'cu': 'application/cu-seeme',
54
+ 'cwl': 'application/cwl',
55
+ 'mpd': 'application/dash+xml',
56
+ 'mpp': 'application/vnd.ms-project',
57
+ 'davmount': 'application/davmount+xml',
58
+ 'dbk': 'application/docbook+xml',
59
+ 'dssc': 'application/dssc+der',
60
+ 'xdssc': 'application/dssc+xml',
61
+ 'ecma': 'application/ecmascript',
62
+ 'emma': 'application/emma+xml',
63
+ 'emotionml': 'application/emotionml+xml',
64
+ 'epub': 'application/epub+zip',
65
+ 'exi': 'application/exi',
66
+ 'exp': 'application/express',
67
+ 'fdf': 'application/vnd.fdf',
68
+ 'fdt': 'application/fdt+xml',
69
+ 'pfr': 'application/font-tdpfr',
70
+ 'geojson': 'application/geo+json',
71
+ 'gml': 'application/gml+xml',
72
+ 'gpx': 'application/gpx+xml',
73
+ 'gxf': 'application/gxf',
74
+ 'gz': 'application/gzip',
75
+ 'hjson': 'application/hjson',
76
+ 'stk': 'application/hyperstudio',
77
+ 'ink': 'application/inkml+xml',
78
+ 'inkml': 'application/inkml+xml',
79
+ 'ipfix': 'application/ipfix',
80
+ 'its': 'application/its+xml',
81
+ 'jar': 'application/java-archive',
82
+ 'war': 'application/java-archive',
83
+ 'ear': 'application/java-archive',
84
+ 'ser': 'application/java-serialized-object',
85
+ 'class': 'application/java-vm',
86
+ 'js': 'application/javascript',
87
+ 'mjs': 'application/javascript',
88
+ 'json': 'application/json',
89
+ 'map': 'application/json',
90
+ 'json5': 'application/json5',
91
+ 'jsonml': 'application/jsonml+json',
92
+ 'jsonld': 'application/ld+json',
93
+ 'lgr': 'application/lgr+xml',
94
+ 'lostxml': 'application/lost+xml',
95
+ 'hqx': 'application/mac-binhex40',
96
+ 'cpt': 'application/mac-compactpro',
97
+ 'mads': 'application/mads+xml',
98
+ 'webmanifest': 'application/manifest+json',
99
+ 'mrc': 'application/marc',
100
+ 'mrcx': 'application/marcxml+xml',
101
+ 'ma': 'application/mathematica',
102
+ 'nb': 'application/mathematica',
103
+ 'mb': 'application/mathematica',
104
+ 'mathml': 'application/mathml+xml',
105
+ 'mbox': 'application/mbox',
106
+ 'mpf': 'application/media-policy-dataset+xml',
107
+ 'mscml': 'application/mediaservercontrol+xml',
108
+ 'metalink': 'application/metalink+xml',
109
+ 'meta4': 'application/metalink4+xml',
110
+ 'mets': 'application/mets+xml',
111
+ 'maei': 'application/mmt-aei+xml',
112
+ 'musd': 'application/mmt-usd+xml',
113
+ 'mods': 'application/mods+xml',
114
+ 'm21': 'application/mp21',
115
+ 'mp21': 'application/mp21',
116
+ 'mp4s': 'application/mp4',
117
+ 'm4p': 'application/mp4',
118
+ 'doc': 'application/msword',
119
+ 'dot': 'application/msword',
120
+ 'mxf': 'application/mxf',
121
+ 'nq': 'application/n-quads',
122
+ 'nt': 'application/n-triples',
123
+ 'cjs': 'application/node',
124
+ 'bin': 'application/octet-stream',
125
+ 'dms': 'application/octet-stream',
126
+ 'lrf': 'application/octet-stream',
127
+ 'mar': 'application/octet-stream',
128
+ 'so': 'application/octet-stream',
129
+ 'dist': 'application/octet-stream',
130
+ 'distz': 'application/octet-stream',
131
+ 'pkg': 'application/octet-stream',
132
+ 'bpk': 'application/octet-stream',
133
+ 'dump': 'application/octet-stream',
134
+ 'elc': 'application/octet-stream',
135
+ 'deploy': 'application/octet-stream',
136
+ 'exe': 'application/x-msdownload',
137
+ 'dll': 'application/x-msdownload',
138
+ 'deb': 'application/x-debian-package',
139
+ 'dmg': 'application/x-apple-diskimage',
140
+ 'iso': 'application/x-iso9660-image',
141
+ 'img': 'application/octet-stream',
142
+ 'msi': 'application/x-msdownload',
143
+ 'msp': 'application/octet-stream',
144
+ 'msm': 'application/octet-stream',
145
+ 'buffer': 'application/octet-stream',
146
+ 'oda': 'application/oda',
147
+ 'opf': 'application/oebps-package+xml',
148
+ 'ogx': 'application/ogg',
149
+ 'omdoc': 'application/omdoc+xml',
150
+ 'onetoc': 'application/onenote',
151
+ 'onetoc2': 'application/onenote',
152
+ 'onetmp': 'application/onenote',
153
+ 'onepkg': 'application/onenote',
154
+ 'oxps': 'application/oxps',
155
+ 'relo': 'application/p2p-overlay+xml',
156
+ 'xer': 'application/patch-ops-error+xml',
157
+ 'pdf': 'application/pdf',
158
+ 'pgp': 'application/pgp-encrypted',
159
+ 'asc': 'application/pgp-signature',
160
+ 'sig': 'application/pgp-signature',
161
+ 'prf': 'application/pics-rules',
162
+ 'p10': 'application/pkcs10',
163
+ 'p7m': 'application/pkcs7-mime',
164
+ 'p7c': 'application/pkcs7-mime',
165
+ 'p7s': 'application/pkcs7-signature',
166
+ 'p8': 'application/pkcs8',
167
+ 'ac': 'application/vnd.nokia.n-gage.ac+xml',
168
+ 'cer': 'application/pkix-cert',
169
+ 'crl': 'application/pkix-crl',
170
+ 'pkipath': 'application/pkix-pkipath',
171
+ 'pki': 'application/pkixcmp',
172
+ 'pls': 'application/pls+xml',
173
+ 'ai': 'application/postscript',
174
+ 'eps': 'application/postscript',
175
+ 'ps': 'application/postscript',
176
+ 'provx': 'application/provenance+xml',
177
+ 'cww': 'application/prs.cww',
178
+ 'pskcxml': 'application/pskc+xml',
179
+ 'raml': 'application/raml+yaml',
180
+ 'rdf': 'application/rdf+xml',
181
+ 'owl': 'application/rdf+xml',
182
+ 'rif': 'application/reginfo+xml',
183
+ 'rnc': 'application/relax-ng-compact-syntax',
184
+ 'rl': 'application/resource-lists+xml',
185
+ 'rld': 'application/resource-lists-diff+xml',
186
+ 'rs': 'application/rls-services+xml',
187
+ 'rapd': 'application/route-apd+xml',
188
+ 'sls': 'application/route-s-tsid+xml',
189
+ 'rusd': 'application/route-usd+xml',
190
+ 'gbr': 'application/rpki-ghostbusters',
191
+ 'mft': 'application/rpki-manifest',
192
+ 'roa': 'application/rpki-roa',
193
+ 'rsd': 'application/rsd+xml',
194
+ 'rss': 'application/rss+xml',
195
+ 'rtf': 'text/rtf',
196
+ 'sbml': 'application/sbml+xml',
197
+ 'scq': 'application/scvp-cv-request',
198
+ 'scs': 'application/scvp-cv-response',
199
+ 'spq': 'application/scvp-vp-request',
200
+ 'spp': 'application/scvp-vp-response',
201
+ 'sdp': 'application/sdp',
202
+ 'senmlx': 'application/senml+xml',
203
+ 'sensmlx': 'application/sensml+xml',
204
+ 'setpay': 'application/set-payment-initiation',
205
+ 'setreg': 'application/set-registration-initiation',
206
+ 'shf': 'application/shf+xml',
207
+ 'siv': 'application/sieve',
208
+ 'sieve': 'application/sieve',
209
+ 'smi': 'application/smil+xml',
210
+ 'smil': 'application/smil+xml',
211
+ 'rq': 'application/sparql-query',
212
+ 'srx': 'application/sparql-results+xml',
213
+ 'gram': 'application/srgs',
214
+ 'grxml': 'application/srgs+xml',
215
+ 'sru': 'application/sru+xml',
216
+ 'ssdl': 'application/ssdl+xml',
217
+ 'ssml': 'application/ssml+xml',
218
+ 'swidtag': 'application/swid+xml',
219
+ 'tei': 'application/tei+xml',
220
+ 'teicorpus': 'application/tei+xml',
221
+ 'tfi': 'application/thraud+xml',
222
+ 'tsd': 'application/timestamped-data',
223
+ 'toml': 'application/toml',
224
+ 'trig': 'application/trig',
225
+ 'ttml': 'application/ttml+xml',
226
+ 'ubj': 'application/ubjson',
227
+ 'rsheet': 'application/urc-ressheet+xml',
228
+ 'td': 'application/urc-targetdesc+xml',
229
+ '1km': 'application/vnd.1000minds.decision-model+xml',
230
+ 'plb': 'application/vnd.3gpp.pic-bw-large',
231
+ 'psb': 'application/vnd.3gpp.pic-bw-small',
232
+ 'pvb': 'application/vnd.3gpp.pic-bw-var',
233
+ 'tcap': 'application/vnd.3gpp2.tcap',
234
+ 'pwn': 'application/vnd.3m.post-it-notes',
235
+ 'aso': 'application/vnd.accpac.simply.aso',
236
+ 'imp': 'application/vnd.accpac.simply.imp',
237
+ 'acu': 'application/vnd.acucobol',
238
+ 'atc': 'application/vnd.acucorp',
239
+ 'acutc': 'application/vnd.acucorp',
240
+ 'air': 'application/vnd.adobe.air-application-installer-package+zip',
241
+ 'fcdt': 'application/vnd.adobe.formscentral.fcdt',
242
+ 'fxp': 'application/vnd.adobe.fxp',
243
+ 'fxpl': 'application/vnd.adobe.fxp',
244
+ 'xdp': 'application/vnd.adobe.xdp+xml',
245
+ 'xfdf': 'application/xfdf',
246
+ 'age': 'application/vnd.age',
247
+ 'ahead': 'application/vnd.ahead.space',
248
+ 'azf': 'application/vnd.airzip.filesecure.azf',
249
+ 'azs': 'application/vnd.airzip.filesecure.azs',
250
+ 'azw': 'application/vnd.amazon.ebook',
251
+ 'acc': 'application/vnd.americandynamics.acc',
252
+ 'ami': 'application/vnd.amiga.ami',
253
+ 'apk': 'application/vnd.android.package-archive',
254
+ 'cii': 'application/vnd.anser-web-certificate-issue-initiation',
255
+ 'fti': 'application/vnd.anser-web-funds-transfer-initiation',
256
+ 'atx': 'application/vnd.antix.game-component',
257
+ 'mpkg': 'application/vnd.apple.installer+xml',
258
+ 'key': 'application/x-iwork-keynote-sffkey',
259
+ 'm3u8': 'application/vnd.apple.mpegurl',
260
+ 'numbers': 'application/x-iwork-numbers-sffnumbers',
261
+ 'pages': 'application/x-iwork-pages-sffpages',
262
+ 'pkpass': 'application/vnd.apple.pkpass',
263
+ 'swi': 'application/vnd.aristanetworks.swi',
264
+ 'iota': 'application/vnd.astraea-software.iota',
265
+ 'aep': 'application/vnd.audiograph',
266
+ 'bmml': 'application/vnd.balsamiq.bmml+xml',
267
+ 'mpm': 'application/vnd.blueice.multipass',
268
+ 'bmi': 'application/vnd.bmi',
269
+ 'rep': 'application/vnd.businessobjects',
270
+ 'cdxml': 'application/vnd.chemdraw+xml',
271
+ 'mmd': 'application/vnd.chipnuts.karaoke-mmd',
272
+ 'cdy': 'application/vnd.cinderella',
273
+ 'csl': 'application/vnd.citationstyles.style+xml',
274
+ 'cla': 'application/vnd.claymore',
275
+ 'rp9': 'application/vnd.cloanto.rp9',
276
+ 'c4g': 'application/vnd.clonk.c4group',
277
+ 'c4d': 'application/vnd.clonk.c4group',
278
+ 'c4f': 'application/vnd.clonk.c4group',
279
+ 'c4p': 'application/vnd.clonk.c4group',
280
+ 'c4u': 'application/vnd.clonk.c4group',
281
+ 'c11amc': 'application/vnd.cluetrust.cartomobile-config',
282
+ 'c11amz': 'application/vnd.cluetrust.cartomobile-config-pkg',
283
+ 'csp': 'application/vnd.commonspace',
284
+ 'cdbcmsg': 'application/vnd.contact.cmsg',
285
+ 'cmc': 'application/vnd.cosmocaller',
286
+ 'clkx': 'application/vnd.crick.clicker',
287
+ 'clkk': 'application/vnd.crick.clicker.keyboard',
288
+ 'clkp': 'application/vnd.crick.clicker.palette',
289
+ 'clkt': 'application/vnd.crick.clicker.template',
290
+ 'clkw': 'application/vnd.crick.clicker.wordbank',
291
+ 'wbs': 'application/vnd.criticaltools.wbs+xml',
292
+ 'pml': 'application/vnd.ctc-posml',
293
+ 'ppd': 'application/vnd.cups-ppd',
294
+ 'car': 'application/vnd.curl.car',
295
+ 'pcurl': 'application/vnd.curl.pcurl',
296
+ 'dart': 'application/vnd.dart',
297
+ 'rdz': 'application/vnd.data-vision.rdz',
298
+ 'dbf': 'application/vnd.dbf',
299
+ 'uvf': 'application/vnd.dece.data',
300
+ 'uvvf': 'application/vnd.dece.data',
301
+ 'uvd': 'application/vnd.dece.data',
302
+ 'uvvd': 'application/vnd.dece.data',
303
+ 'uvt': 'application/vnd.dece.ttml+xml',
304
+ 'uvvt': 'application/vnd.dece.ttml+xml',
305
+ 'uvx': 'application/vnd.dece.unspecified',
306
+ 'uvvx': 'application/vnd.dece.unspecified',
307
+ 'uvz': 'application/vnd.dece.zip',
308
+ 'uvvz': 'application/vnd.dece.zip',
309
+ 'fe_launch': 'application/vnd.denovo.fcselayout-link',
310
+ 'dna': 'application/vnd.dna',
311
+ 'mlp': 'application/vnd.dolby.mlp',
312
+ 'dpg': 'application/vnd.dpgraph',
313
+ 'dfac': 'application/vnd.dreamfactory',
314
+ 'kpxx': 'application/vnd.ds-keypoint',
315
+ 'ait': 'application/vnd.dvb.ait',
316
+ 'svc': 'application/vnd.dvb.service',
317
+ 'geo': 'application/vnd.dynageo',
318
+ 'mag': 'application/vnd.ecowin.chart',
319
+ 'nml': 'application/vnd.enliven',
320
+ 'esf': 'application/vnd.epson.esf',
321
+ 'msf': 'application/vnd.epson.msf',
322
+ 'qam': 'application/vnd.epson.quickanime',
323
+ 'slt': 'application/vnd.epson.salt',
324
+ 'ssf': 'application/vnd.epson.ssf',
325
+ 'es3': 'application/vnd.eszigno3+xml',
326
+ 'et3': 'application/vnd.eszigno3+xml',
327
+ 'ez2': 'application/vnd.ezpix-album',
328
+ 'ez3': 'application/vnd.ezpix-package',
329
+ 'mseed': 'application/vnd.fdsn.mseed',
330
+ 'seed': 'application/vnd.fdsn.seed',
331
+ 'dataless': 'application/vnd.fdsn.seed',
332
+ 'gph': 'application/vnd.flographit',
333
+ 'ftc': 'application/vnd.fluxtime.clip',
334
+ 'fm': 'application/vnd.framemaker',
335
+ 'frame': 'application/vnd.framemaker',
336
+ 'maker': 'application/vnd.framemaker',
337
+ 'book': 'application/vnd.framemaker',
338
+ 'fnc': 'application/vnd.frogans.fnc',
339
+ 'ltf': 'application/vnd.frogans.ltf',
340
+ 'fsc': 'application/vnd.fsc.weblaunch',
341
+ 'oas': 'application/vnd.fujitsu.oasys',
342
+ 'oa2': 'application/vnd.fujitsu.oasys2',
343
+ 'oa3': 'application/vnd.fujitsu.oasys3',
344
+ 'fg5': 'application/vnd.fujitsu.oasysgp',
345
+ 'bh2': 'application/vnd.fujitsu.oasysprs',
346
+ 'ddd': 'application/vnd.fujixerox.ddd',
347
+ 'xdw': 'application/vnd.fujixerox.docuworks',
348
+ 'xbd': 'application/vnd.fujixerox.docuworks.binder',
349
+ 'fzs': 'application/vnd.fuzzysheet',
350
+ 'txd': 'application/vnd.genomatix.tuxedo',
351
+ 'ggb': 'application/vnd.geogebra.file',
352
+ 'ggt': 'application/vnd.geogebra.tool',
353
+ 'gex': 'application/vnd.geometry-explorer',
354
+ 'gre': 'application/vnd.geometry-explorer',
355
+ 'gxt': 'application/vnd.geonext',
356
+ 'g2w': 'application/vnd.geoplan',
357
+ 'g3w': 'application/vnd.geospace',
358
+ 'gmx': 'application/vnd.gmx',
359
+ 'gdoc': 'application/vnd.google-apps.document',
360
+ 'gslides': 'application/vnd.google-apps.presentation',
361
+ 'gsheet': 'application/vnd.google-apps.spreadsheet',
362
+ 'kml': 'application/vnd.google-earth.kml+xml',
363
+ 'kmz': 'application/vnd.google-earth.kmz',
364
+ 'gqf': 'application/vnd.grafeq',
365
+ 'gqs': 'application/vnd.grafeq',
366
+ 'gac': 'application/vnd.groove-account',
367
+ 'ghf': 'application/vnd.groove-help',
368
+ 'gim': 'application/vnd.groove-identity-message',
369
+ 'grv': 'application/vnd.groove-injector',
370
+ 'gtm': 'application/vnd.groove-tool-message',
371
+ 'tpl': 'application/vnd.groove-tool-template',
372
+ 'vcg': 'application/vnd.groove-vcard',
373
+ 'hal': 'application/vnd.hal+xml',
374
+ 'zmm': 'application/vnd.handheld-entertainment+xml',
375
+ 'hbci': 'application/vnd.hbci',
376
+ 'les': 'application/vnd.hhe.lesson-player',
377
+ 'hpgl': 'application/vnd.hp-hpgl',
378
+ 'hpid': 'application/vnd.hp-hpid',
379
+ 'hps': 'application/vnd.hp-hps',
380
+ 'jlt': 'application/vnd.hp-jlyt',
381
+ 'pcl': 'application/vnd.hp-pcl',
382
+ 'pclxl': 'application/vnd.hp-pclxl',
383
+ 'sfd-hdstx': 'application/vnd.hydrostatix.sof-data',
384
+ 'mpy': 'application/vnd.ibm.minipay',
385
+ 'afp': 'application/vnd.ibm.modcap',
386
+ 'listafp': 'application/vnd.ibm.modcap',
387
+ 'list3820': 'application/vnd.ibm.modcap',
388
+ 'irm': 'application/vnd.ibm.rights-management',
389
+ 'sc': 'application/vnd.ibm.secure-container',
390
+ 'icc': 'application/vnd.iccprofile',
391
+ 'icm': 'application/vnd.iccprofile',
392
+ 'igl': 'application/vnd.igloader',
393
+ 'ivp': 'application/vnd.immervision-ivp',
394
+ 'ivu': 'application/vnd.immervision-ivu',
395
+ 'igm': 'application/vnd.insors.igm',
396
+ 'xpw': 'application/vnd.intercon.formnet',
397
+ 'xpx': 'application/vnd.intercon.formnet',
398
+ 'i2g': 'application/vnd.intergeo',
399
+ 'qbo': 'application/vnd.intu.qbo',
400
+ 'qfx': 'application/vnd.intu.qfx',
401
+ 'rcprofile': 'application/vnd.ipunplugged.rcprofile',
402
+ 'irp': 'application/vnd.irepository.package+xml',
403
+ 'xpr': 'application/vnd.is-xpr',
404
+ 'fcs': 'application/vnd.isac.fcs',
405
+ 'jam': 'application/vnd.jam',
406
+ 'rms': 'application/vnd.jcp.javame.midlet-rms',
407
+ 'jisp': 'application/vnd.jisp',
408
+ 'joda': 'application/vnd.joost.joda-archive',
409
+ 'ktz': 'application/vnd.kahootz',
410
+ 'ktr': 'application/vnd.kahootz',
411
+ 'karbon': 'application/vnd.kde.karbon',
412
+ 'chrt': 'application/vnd.kde.kchart',
413
+ 'kfo': 'application/vnd.kde.kformula',
414
+ 'flw': 'application/vnd.kde.kivio',
415
+ 'kon': 'application/vnd.kde.kontour',
416
+ 'kpr': 'application/vnd.kde.kpresenter',
417
+ 'kpt': 'application/vnd.kde.kpresenter',
418
+ 'ksp': 'application/vnd.kde.kspread',
419
+ 'kwd': 'application/vnd.kde.kword',
420
+ 'kwt': 'application/vnd.kde.kword',
421
+ 'htke': 'application/vnd.kenameaapp',
422
+ 'kia': 'application/vnd.kidspiration',
423
+ 'kne': 'application/vnd.kinar',
424
+ 'knp': 'application/vnd.kinar',
425
+ 'skp': 'application/vnd.koan',
426
+ 'skd': 'application/vnd.koan',
427
+ 'skt': 'application/vnd.koan',
428
+ 'skm': 'application/vnd.koan',
429
+ 'sse': 'application/vnd.kodak-descriptor',
430
+ 'lasxml': 'application/vnd.las.las+xml',
431
+ 'lbd': 'application/vnd.llamagraphics.life-balance.desktop',
432
+ 'lbe': 'application/vnd.llamagraphics.life-balance.exchange+xml',
433
+ 'apr': 'application/vnd.lotus-approach',
434
+ 'pre': 'application/vnd.lotus-freelance',
435
+ 'nsf': 'application/vnd.lotus-notes',
436
+ 'org': 'text/x-org',
437
+ 'scm': 'application/vnd.lotus-screencam',
438
+ 'lwp': 'application/vnd.lotus-wordpro',
439
+ 'portpkg': 'application/vnd.macports.portpkg',
440
+ 'mvt': 'application/vnd.mapbox-vector-tile',
441
+ 'mcd': 'application/vnd.mcd',
442
+ 'mc1': 'application/vnd.medcalcdata',
443
+ 'cdkey': 'application/vnd.mediastation.cdkey',
444
+ 'mwf': 'application/vnd.mfer',
445
+ 'mfm': 'application/vnd.mfmp',
446
+ 'flo': 'application/vnd.micrografx.flo',
447
+ 'igx': 'application/vnd.micrografx.igx',
448
+ 'mif': 'application/vnd.mif',
449
+ 'daf': 'application/vnd.mobius.daf',
450
+ 'dis': 'application/vnd.mobius.dis',
451
+ 'mbk': 'application/vnd.mobius.mbk',
452
+ 'mqy': 'application/vnd.mobius.mqy',
453
+ 'msl': 'application/vnd.mobius.msl',
454
+ 'plc': 'application/vnd.mobius.plc',
455
+ 'txf': 'application/vnd.mobius.txf',
456
+ 'mpn': 'application/vnd.mophun.application',
457
+ 'mpc': 'application/vnd.mophun.certificate',
458
+ 'xul': 'application/vnd.mozilla.xul+xml',
459
+ 'cil': 'application/vnd.ms-artgalry',
460
+ 'cab': 'application/vnd.ms-cab-compressed',
461
+ 'xls': 'application/vnd.ms-excel',
462
+ 'xlm': 'application/vnd.ms-excel',
463
+ 'xla': 'application/vnd.ms-excel',
464
+ 'xlc': 'application/vnd.ms-excel',
465
+ 'xlt': 'application/vnd.ms-excel',
466
+ 'xlw': 'application/vnd.ms-excel',
467
+ 'xlam': 'application/vnd.ms-excel.addin.macroenabled.12',
468
+ 'xlsb': 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
469
+ 'xlsm': 'application/vnd.ms-excel.sheet.macroenabled.12',
470
+ 'xltm': 'application/vnd.ms-excel.template.macroenabled.12',
471
+ 'eot': 'application/vnd.ms-fontobject',
472
+ 'chm': 'application/vnd.ms-htmlhelp',
473
+ 'ims': 'application/vnd.ms-ims',
474
+ 'lrm': 'application/vnd.ms-lrm',
475
+ 'thmx': 'application/vnd.ms-officetheme',
476
+ 'msg': 'application/vnd.ms-outlook',
477
+ 'cat': 'application/vnd.ms-pki.seccat',
478
+ 'stl': 'model/stl',
479
+ 'ppt': 'application/vnd.ms-powerpoint',
480
+ 'pps': 'application/vnd.ms-powerpoint',
481
+ 'pot': 'application/vnd.ms-powerpoint',
482
+ 'ppam': 'application/vnd.ms-powerpoint.addin.macroenabled.12',
483
+ 'pptm': 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
484
+ 'sldm': 'application/vnd.ms-powerpoint.slide.macroenabled.12',
485
+ 'ppsm': 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
486
+ 'potm': 'application/vnd.ms-powerpoint.template.macroenabled.12',
487
+ 'mpt': 'application/vnd.ms-project',
488
+ 'docm': 'application/vnd.ms-word.document.macroenabled.12',
489
+ 'dotm': 'application/vnd.ms-word.template.macroenabled.12',
490
+ 'wps': 'application/vnd.ms-works',
491
+ 'wks': 'application/vnd.ms-works',
492
+ 'wcm': 'application/vnd.ms-works',
493
+ 'wdb': 'application/vnd.ms-works',
494
+ 'wpl': 'application/vnd.ms-wpl',
495
+ 'xps': 'application/vnd.ms-xpsdocument',
496
+ 'mseq': 'application/vnd.mseq',
497
+ 'mus': 'application/vnd.musician',
498
+ 'msty': 'application/vnd.muvee.style',
499
+ 'taglet': 'application/vnd.mynfc',
500
+ 'nlu': 'application/vnd.neurolanguage.nlu',
501
+ 'ntf': 'application/vnd.nitf',
502
+ 'nitf': 'application/vnd.nitf',
503
+ 'nnd': 'application/vnd.noblenet-directory',
504
+ 'nns': 'application/vnd.noblenet-sealer',
505
+ 'nnw': 'application/vnd.noblenet-web',
506
+ 'ngdat': 'application/vnd.nokia.n-gage.data',
507
+ 'n-gage': 'application/vnd.nokia.n-gage.symbian.install',
508
+ 'rpst': 'application/vnd.nokia.radio-preset',
509
+ 'rpss': 'application/vnd.nokia.radio-presets',
510
+ 'edm': 'application/vnd.novadigm.edm',
511
+ 'edx': 'application/vnd.novadigm.edx',
512
+ 'ext': 'application/vnd.novadigm.ext',
513
+ 'odc': 'application/vnd.oasis.opendocument.chart',
514
+ 'otc': 'application/vnd.oasis.opendocument.chart-template',
515
+ 'odb': 'application/vnd.oasis.opendocument.database',
516
+ 'odf': 'application/vnd.oasis.opendocument.formula',
517
+ 'odft': 'application/vnd.oasis.opendocument.formula-template',
518
+ 'odg': 'application/vnd.oasis.opendocument.graphics',
519
+ 'otg': 'application/vnd.oasis.opendocument.graphics-template',
520
+ 'odi': 'application/vnd.oasis.opendocument.image',
521
+ 'oti': 'application/vnd.oasis.opendocument.image-template',
522
+ 'odp': 'application/vnd.oasis.opendocument.presentation',
523
+ 'otp': 'application/vnd.oasis.opendocument.presentation-template',
524
+ 'ods': 'application/vnd.oasis.opendocument.spreadsheet',
525
+ 'ots': 'application/vnd.oasis.opendocument.spreadsheet-template',
526
+ 'odt': 'application/vnd.oasis.opendocument.text',
527
+ 'odm': 'application/vnd.oasis.opendocument.text-master',
528
+ 'ott': 'application/vnd.oasis.opendocument.text-template',
529
+ 'oth': 'application/vnd.oasis.opendocument.text-web',
530
+ 'xo': 'application/vnd.olpc-sugar',
531
+ 'dd2': 'application/vnd.oma.dd2+xml',
532
+ 'obgx': 'application/vnd.openblox.game+xml',
533
+ 'oxt': 'application/vnd.openofficeorg.extension',
534
+ 'osm': 'application/vnd.openstreetmap.data+xml',
535
+ 'pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
536
+ 'sldx': 'application/vnd.openxmlformats-officedocument.presentationml.slide',
537
+ 'ppsx': 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
538
+ 'potx': 'application/vnd.openxmlformats-officedocument.presentationml.template',
539
+ 'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
540
+ 'xltx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
541
+ 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
542
+ 'dotx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
543
+ 'mgp': 'application/vnd.osgeo.mapguide.package',
544
+ 'dp': 'application/vnd.osgi.dp',
545
+ 'esa': 'application/vnd.osgi.subsystem',
546
+ 'pdb': 'application/x-pilot',
547
+ 'pqa': 'application/vnd.palm',
548
+ 'oprc': 'application/vnd.palm',
549
+ 'paw': 'application/vnd.pawaafile',
550
+ 'str': 'application/vnd.pg.format',
551
+ 'ei6': 'application/vnd.pg.osasli',
552
+ 'efif': 'application/vnd.picsel',
553
+ 'wg': 'application/vnd.pmi.widget',
554
+ 'plf': 'application/vnd.pocketlearn',
555
+ 'pbd': 'application/vnd.powerbuilder6',
556
+ 'box': 'application/vnd.previewsystems.box',
557
+ 'mgz': 'application/vnd.proteus.magazine',
558
+ 'qps': 'application/vnd.publishare-delta-tree',
559
+ 'ptid': 'application/vnd.pvi.ptid1',
560
+ 'qxd': 'application/vnd.quark.quarkxpress',
561
+ 'qxt': 'application/vnd.quark.quarkxpress',
562
+ 'qwd': 'application/vnd.quark.quarkxpress',
563
+ 'qwt': 'application/vnd.quark.quarkxpress',
564
+ 'qxl': 'application/vnd.quark.quarkxpress',
565
+ 'qxb': 'application/vnd.quark.quarkxpress',
566
+ 'rar': 'application/x-rar-compressed',
567
+ 'bed': 'application/vnd.realvnc.bed',
568
+ 'mxl': 'application/vnd.recordare.musicxml',
569
+ 'musicxml': 'application/vnd.recordare.musicxml+xml',
570
+ 'cryptonote': 'application/vnd.rig.cryptonote',
571
+ 'cod': 'application/vnd.rim.cod',
572
+ 'rm': 'application/vnd.rn-realmedia',
573
+ 'rmvb': 'application/vnd.rn-realmedia-vbr',
574
+ 'link66': 'application/vnd.route66.link66+xml',
575
+ 'st': 'application/vnd.sailingtracker.track',
576
+ 'see': 'application/vnd.seemail',
577
+ 'sema': 'application/vnd.sema',
578
+ 'semd': 'application/vnd.semd',
579
+ 'semf': 'application/vnd.semf',
580
+ 'ifm': 'application/vnd.shana.informed.formdata',
581
+ 'itp': 'application/vnd.shana.informed.formtemplate',
582
+ 'iif': 'application/vnd.shana.informed.interchange',
583
+ 'ipk': 'application/vnd.shana.informed.package',
584
+ 'twd': 'application/vnd.simtech-mindmapper',
585
+ 'twds': 'application/vnd.simtech-mindmapper',
586
+ 'mmf': 'application/vnd.smaf',
587
+ 'teacher': 'application/vnd.smart.teacher',
588
+ 'fo': 'application/vnd.software602.filler.form+xml',
589
+ 'sdkm': 'application/vnd.solent.sdkm+xml',
590
+ 'sdkd': 'application/vnd.solent.sdkm+xml',
591
+ 'dxp': 'application/vnd.spotfire.dxp',
592
+ 'sfs': 'application/vnd.spotfire.sfs',
593
+ 'sdc': 'application/vnd.stardivision.calc',
594
+ 'sda': 'application/vnd.stardivision.draw',
595
+ 'sdd': 'application/vnd.stardivision.impress',
596
+ 'smf': 'application/vnd.stardivision.math',
597
+ 'sdw': 'application/vnd.stardivision.writer',
598
+ 'vor': 'application/vnd.stardivision.writer',
599
+ 'sgl': 'application/vnd.stardivision.writer-global',
600
+ 'smzip': 'application/vnd.stepmania.package',
601
+ 'sm': 'application/vnd.stepmania.stepchart',
602
+ 'wadl': 'application/vnd.sun.wadl+xml',
603
+ 'sxc': 'application/vnd.sun.xml.calc',
604
+ 'stc': 'application/vnd.sun.xml.calc.template',
605
+ 'sxd': 'application/vnd.sun.xml.draw',
606
+ 'std': 'application/vnd.sun.xml.draw.template',
607
+ 'sxi': 'application/vnd.sun.xml.impress',
608
+ 'sti': 'application/vnd.sun.xml.impress.template',
609
+ 'sxm': 'application/vnd.sun.xml.math',
610
+ 'sxw': 'application/vnd.sun.xml.writer',
611
+ 'sxg': 'application/vnd.sun.xml.writer.global',
612
+ 'stw': 'application/vnd.sun.xml.writer.template',
613
+ 'sus': 'application/vnd.sus-calendar',
614
+ 'susp': 'application/vnd.sus-calendar',
615
+ 'svd': 'application/vnd.svd',
616
+ 'sis': 'application/vnd.symbian.install',
617
+ 'sisx': 'application/vnd.symbian.install',
618
+ 'xsm': 'application/vnd.syncml+xml',
619
+ 'bdm': 'application/vnd.syncml.dm+wbxml',
620
+ 'xdm': 'application/vnd.syncml.dm+xml',
621
+ 'ddf': 'application/vnd.syncml.dmddf+xml',
622
+ 'tao': 'application/vnd.tao.intent-module-archive',
623
+ 'pcap': 'application/vnd.tcpdump.pcap',
624
+ 'cap': 'application/vnd.tcpdump.pcap',
625
+ 'dmp': 'application/vnd.tcpdump.pcap',
626
+ 'tmo': 'application/vnd.tmobile-livetv',
627
+ 'tpt': 'application/vnd.trid.tpt',
628
+ 'mxs': 'application/vnd.triscape.mxs',
629
+ 'tra': 'application/vnd.trueapp',
630
+ 'ufd': 'application/vnd.ufdl',
631
+ 'ufdl': 'application/vnd.ufdl',
632
+ 'utz': 'application/vnd.uiq.theme',
633
+ 'umj': 'application/vnd.umajin',
634
+ 'unityweb': 'application/vnd.unity',
635
+ 'uoml': 'application/vnd.uoml+xml',
636
+ 'vcx': 'application/vnd.vcx',
637
+ 'vsd': 'application/vnd.visio',
638
+ 'vst': 'application/vnd.visio',
639
+ 'vss': 'application/vnd.visio',
640
+ 'vsw': 'application/vnd.visio',
641
+ 'vis': 'application/vnd.visionary',
642
+ 'vsf': 'application/vnd.vsf',
643
+ 'wbxml': 'application/vnd.wap.wbxml',
644
+ 'wmlc': 'application/vnd.wap.wmlc',
645
+ 'wmlsc': 'application/vnd.wap.wmlscriptc',
646
+ 'wtb': 'application/vnd.webturbo',
647
+ 'nbp': 'application/vnd.wolfram.player',
648
+ 'wpd': 'application/vnd.wordperfect',
649
+ 'wqd': 'application/vnd.wqd',
650
+ 'stf': 'application/vnd.wt.stf',
651
+ 'xar': 'application/vnd.xara',
652
+ 'xfdl': 'application/vnd.xfdl',
653
+ 'hvd': 'application/vnd.yamaha.hv-dic',
654
+ 'hvs': 'application/vnd.yamaha.hv-script',
655
+ 'hvp': 'application/vnd.yamaha.hv-voice',
656
+ 'osf': 'application/vnd.yamaha.openscoreformat',
657
+ 'osfpvg': 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
658
+ 'saf': 'application/vnd.yamaha.smaf-audio',
659
+ 'spf': 'application/vnd.yamaha.smaf-phrase',
660
+ 'cmp': 'application/vnd.yellowriver-custom-menu',
661
+ 'zir': 'application/vnd.zul',
662
+ 'zirz': 'application/vnd.zul',
663
+ 'zaz': 'application/vnd.zzazz.deck+xml',
664
+ 'vxml': 'application/voicexml+xml',
665
+ 'wasm': 'application/wasm',
666
+ 'wif': 'application/watcherinfo+xml',
667
+ 'wgt': 'application/widget',
668
+ 'hlp': 'application/winhlp',
669
+ 'wsdl': 'application/wsdl+xml',
670
+ 'wspolicy': 'application/wspolicy+xml',
671
+ '7z': 'application/x-7z-compressed',
672
+ 'abw': 'application/x-abiword',
673
+ 'ace': 'application/x-ace-compressed',
674
+ 'arj': 'application/x-arj',
675
+ 'aab': 'application/x-authorware-bin',
676
+ 'x32': 'application/x-authorware-bin',
677
+ 'u32': 'application/x-authorware-bin',
678
+ 'vox': 'application/x-authorware-bin',
679
+ 'aam': 'application/x-authorware-map',
680
+ 'aas': 'application/x-authorware-seg',
681
+ 'bcpio': 'application/x-bcpio',
682
+ 'torrent': 'application/x-bittorrent',
683
+ 'blb': 'application/x-blorb',
684
+ 'blorb': 'application/x-blorb',
685
+ 'bz': 'application/x-bzip',
686
+ 'bz2': 'application/x-bzip2',
687
+ 'boz': 'application/x-bzip2',
688
+ 'cbr': 'application/x-cbr',
689
+ 'cba': 'application/x-cbr',
690
+ 'cbt': 'application/x-cbr',
691
+ 'cbz': 'application/x-cbr',
692
+ 'cb7': 'application/x-cbr',
693
+ 'vcd': 'application/x-cdlink',
694
+ 'cfs': 'application/x-cfs-compressed',
695
+ 'chat': 'application/x-chat',
696
+ 'pgn': 'application/x-chess-pgn',
697
+ 'crx': 'application/x-chrome-extension',
698
+ 'cco': 'application/x-cocoa',
699
+ 'nsc': 'application/x-conference',
700
+ 'cpio': 'application/x-cpio',
701
+ 'csh': 'application/x-csh',
702
+ 'udeb': 'application/x-debian-package',
703
+ 'dgc': 'application/x-dgc-compressed',
704
+ 'dir': 'application/x-director',
705
+ 'dcr': 'application/x-director',
706
+ 'dxr': 'application/x-director',
707
+ 'cst': 'application/x-director',
708
+ 'cct': 'application/x-director',
709
+ 'cxt': 'application/x-director',
710
+ 'w3d': 'application/x-director',
711
+ 'fgd': 'application/x-director',
712
+ 'swa': 'application/x-director',
713
+ 'wad': 'application/x-doom',
714
+ 'ncx': 'application/x-dtbncx+xml',
715
+ 'dtb': 'application/x-dtbook+xml',
716
+ 'res': 'application/x-dtbresource+xml',
717
+ 'dvi': 'application/x-dvi',
718
+ 'evy': 'application/x-envoy',
719
+ 'eva': 'application/x-eva',
720
+ 'bdf': 'application/x-font-bdf',
721
+ 'gsf': 'application/x-font-ghostscript',
722
+ 'psf': 'application/x-font-linux-psf',
723
+ 'pcf': 'application/x-font-pcf',
724
+ 'snf': 'application/x-font-snf',
725
+ 'pfa': 'application/x-font-type1',
726
+ 'pfb': 'application/x-font-type1',
727
+ 'pfm': 'application/x-font-type1',
728
+ 'afm': 'application/x-font-type1',
729
+ 'arc': 'application/x-freearc',
730
+ 'spl': 'application/x-futuresplash',
731
+ 'gca': 'application/x-gca-compressed',
732
+ 'ulx': 'application/x-glulx',
733
+ 'gnumeric': 'application/x-gnumeric',
734
+ 'gramps': 'application/x-gramps-xml',
735
+ 'gtar': 'application/x-gtar',
736
+ 'hdf': 'application/x-hdf',
737
+ 'php': 'application/x-httpd-php',
738
+ 'install': 'application/x-install-instructions',
739
+ 'jardiff': 'application/x-java-archive-diff',
740
+ 'jnlp': 'application/x-java-jnlp-file',
741
+ 'kdbx': 'application/x-keepass2',
742
+ 'latex': 'application/x-latex',
743
+ 'luac': 'application/x-lua-bytecode',
744
+ 'lzh': 'application/x-lzh-compressed',
745
+ 'lha': 'application/x-lzh-compressed',
746
+ 'run': 'application/x-makeself',
747
+ 'mie': 'application/x-mie',
748
+ 'prc': 'model/prc',
749
+ 'mobi': 'application/x-mobipocket-ebook',
750
+ 'application': 'application/x-ms-application',
751
+ 'lnk': 'application/x-ms-shortcut',
752
+ 'wmd': 'application/x-ms-wmd',
753
+ 'wmz': 'application/x-msmetafile',
754
+ 'xbap': 'application/x-ms-xbap',
755
+ 'mdb': 'application/x-msaccess',
756
+ 'obd': 'application/x-msbinder',
757
+ 'crd': 'application/x-mscardfile',
758
+ 'clp': 'application/x-msclip',
759
+ 'com': 'application/x-msdownload',
760
+ 'bat': 'application/x-msdownload',
761
+ 'mvb': 'application/x-msmediaview',
762
+ 'm13': 'application/x-msmediaview',
763
+ 'm14': 'application/x-msmediaview',
764
+ 'wmf': 'image/wmf',
765
+ 'emf': 'image/emf',
766
+ 'emz': 'application/x-msmetafile',
767
+ 'mny': 'application/x-msmoney',
768
+ 'pub': 'application/x-mspublisher',
769
+ 'scd': 'application/x-msschedule',
770
+ 'trm': 'application/x-msterminal',
771
+ 'wri': 'application/x-mswrite',
772
+ 'nc': 'application/x-netcdf',
773
+ 'cdf': 'application/x-netcdf',
774
+ 'pac': 'application/x-ns-proxy-autoconfig',
775
+ 'nzb': 'application/x-nzb',
776
+ 'pl': 'application/x-perl',
777
+ 'pm': 'application/x-perl',
778
+ 'p12': 'application/x-pkcs12',
779
+ 'pfx': 'application/x-pkcs12',
780
+ 'p7b': 'application/x-pkcs7-certificates',
781
+ 'spc': 'application/x-pkcs7-certificates',
782
+ 'p7r': 'application/x-pkcs7-certreqresp',
783
+ 'rpm': 'application/x-redhat-package-manager',
784
+ 'ris': 'application/x-research-info-systems',
785
+ 'sea': 'application/x-sea',
786
+ 'sh': 'application/x-sh',
787
+ 'shar': 'application/x-shar',
788
+ 'swf': 'application/x-shockwave-flash',
789
+ 'xap': 'application/x-silverlight-app',
790
+ 'sql': 'application/x-sql',
791
+ 'sit': 'application/x-stuffit',
792
+ 'sitx': 'application/x-stuffitx',
793
+ 'srt': 'application/x-subrip',
794
+ 'sv4cpio': 'application/x-sv4cpio',
795
+ 'sv4crc': 'application/x-sv4crc',
796
+ 't3': 'application/x-t3vm-image',
797
+ 'gam': 'application/x-tads',
798
+ 'tar': 'application/x-tar',
799
+ 'tcl': 'application/x-tcl',
800
+ 'tk': 'application/x-tcl',
801
+ 'tex': 'application/x-tex',
802
+ 'tfm': 'application/x-tex-tfm',
803
+ 'texinfo': 'application/x-texinfo',
804
+ 'texi': 'application/x-texinfo',
805
+ 'obj': 'model/obj',
806
+ 'ustar': 'application/x-ustar',
807
+ 'hdd': 'application/x-virtualbox-hdd',
808
+ 'ova': 'application/x-virtualbox-ova',
809
+ 'ovf': 'application/x-virtualbox-ovf',
810
+ 'vbox': 'application/x-virtualbox-vbox',
811
+ 'vbox-extpack': 'application/x-virtualbox-vbox-extpack',
812
+ 'vdi': 'application/x-virtualbox-vdi',
813
+ 'vhd': 'application/x-virtualbox-vhd',
814
+ 'vmdk': 'application/x-virtualbox-vmdk',
815
+ 'src': 'application/x-wais-source',
816
+ 'webapp': 'application/x-web-app-manifest+json',
817
+ 'der': 'application/x-x509-ca-cert',
818
+ 'crt': 'application/x-x509-ca-cert',
819
+ 'pem': 'application/x-x509-ca-cert',
820
+ 'fig': 'application/x-xfig',
821
+ 'xlf': 'application/xliff+xml',
822
+ 'xpi': 'application/x-xpinstall',
823
+ 'xz': 'application/x-xz',
824
+ 'z1': 'application/x-zmachine',
825
+ 'z2': 'application/x-zmachine',
826
+ 'z3': 'application/x-zmachine',
827
+ 'z4': 'application/x-zmachine',
828
+ 'z5': 'application/x-zmachine',
829
+ 'z6': 'application/x-zmachine',
830
+ 'z7': 'application/x-zmachine',
831
+ 'z8': 'application/x-zmachine',
832
+ 'xaml': 'application/xaml+xml',
833
+ 'xav': 'application/xcap-att+xml',
834
+ 'xca': 'application/xcap-caps+xml',
835
+ 'xdf': 'application/xcap-diff+xml',
836
+ 'xel': 'application/xcap-el+xml',
837
+ 'xns': 'application/xcap-ns+xml',
838
+ 'xenc': 'application/xenc+xml',
839
+ 'xhtml': 'application/xhtml+xml',
840
+ 'xht': 'application/xhtml+xml',
841
+ 'xml': 'text/xml',
842
+ 'xsl': 'application/xslt+xml',
843
+ 'xsd': 'application/xml',
844
+ 'rng': 'application/xml',
845
+ 'dtd': 'application/xml-dtd',
846
+ 'xop': 'application/xop+xml',
847
+ 'xpl': 'application/xproc+xml',
848
+ 'xslt': 'application/xslt+xml',
849
+ 'xspf': 'application/xspf+xml',
850
+ 'mxml': 'application/xv+xml',
851
+ 'xhvml': 'application/xv+xml',
852
+ 'xvml': 'application/xv+xml',
853
+ 'xvm': 'application/xv+xml',
854
+ 'yang': 'application/yang',
855
+ 'yin': 'application/yin+xml',
856
+ 'zip': 'application/zip',
857
+ '3gpp': 'video/3gpp',
858
+ 'adp': 'audio/adpcm',
859
+ 'amr': 'audio/amr',
860
+ 'au': 'audio/basic',
861
+ 'snd': 'audio/basic',
862
+ 'mid': 'audio/midi',
863
+ 'midi': 'audio/midi',
864
+ 'kar': 'audio/midi',
865
+ 'rmi': 'audio/midi',
866
+ 'mxmf': 'audio/mobile-xmf',
867
+ 'mp3': 'audio/mpeg',
868
+ 'm4a': 'audio/x-m4a',
869
+ 'mp4a': 'audio/mp4',
870
+ 'mpga': 'audio/mpeg',
871
+ 'mp2': 'audio/mpeg',
872
+ 'mp2a': 'audio/mpeg',
873
+ 'm2a': 'audio/mpeg',
874
+ 'm3a': 'audio/mpeg',
875
+ 'oga': 'audio/ogg',
876
+ 'ogg': 'audio/ogg',
877
+ 'spx': 'audio/ogg',
878
+ 'opus': 'audio/ogg',
879
+ 's3m': 'audio/s3m',
880
+ 'sil': 'audio/silk',
881
+ 'uva': 'audio/vnd.dece.audio',
882
+ 'uvva': 'audio/vnd.dece.audio',
883
+ 'eol': 'audio/vnd.digital-winds',
884
+ 'dra': 'audio/vnd.dra',
885
+ 'dts': 'audio/vnd.dts',
886
+ 'dtshd': 'audio/vnd.dts.hd',
887
+ 'lvp': 'audio/vnd.lucent.voice',
888
+ 'pya': 'audio/vnd.ms-playready.media.pya',
889
+ 'ecelp4800': 'audio/vnd.nuera.ecelp4800',
890
+ 'ecelp7470': 'audio/vnd.nuera.ecelp7470',
891
+ 'ecelp9600': 'audio/vnd.nuera.ecelp9600',
892
+ 'rip': 'audio/vnd.rip',
893
+ 'wav': 'audio/x-wav',
894
+ 'weba': 'audio/webm',
895
+ 'aac': 'audio/x-aac',
896
+ 'aif': 'audio/x-aiff',
897
+ 'aiff': 'audio/x-aiff',
898
+ 'aifc': 'audio/x-aiff',
899
+ 'caf': 'audio/x-caf',
900
+ 'flac': 'audio/x-flac',
901
+ 'mka': 'audio/x-matroska',
902
+ 'm3u': 'audio/x-mpegurl',
903
+ 'wax': 'audio/x-ms-wax',
904
+ 'wma': 'audio/x-ms-wma',
905
+ 'ram': 'audio/x-pn-realaudio',
906
+ 'ra': 'audio/x-realaudio',
907
+ 'rmp': 'audio/x-pn-realaudio-plugin',
908
+ 'xm': 'audio/xm',
909
+ 'cdx': 'chemical/x-cdx',
910
+ 'cif': 'chemical/x-cif',
911
+ 'cmdf': 'chemical/x-cmdf',
912
+ 'cml': 'chemical/x-cml',
913
+ 'csml': 'chemical/x-csml',
914
+ 'xyz': 'chemical/x-xyz',
915
+ 'ttc': 'font/collection',
916
+ 'otf': 'font/otf',
917
+ 'ttf': 'font/ttf',
918
+ 'woff': 'font/woff',
919
+ 'woff2': 'font/woff2',
920
+ 'exr': 'image/aces',
921
+ 'apng': 'image/apng',
922
+ 'avci': 'image/avci',
923
+ 'avcs': 'image/avcs',
924
+ 'avif': 'image/avif',
925
+ 'bmp': 'image/x-ms-bmp',
926
+ 'cgm': 'image/cgm',
927
+ 'drle': 'image/dicom-rle',
928
+ 'fits': 'image/fits',
929
+ 'g3': 'image/g3fax',
930
+ 'gif': 'image/gif',
931
+ 'heic': 'image/heic',
932
+ 'heics': 'image/heic-sequence',
933
+ 'heif': 'image/heif',
934
+ 'heifs': 'image/heif-sequence',
935
+ 'hej2': 'image/hej2k',
936
+ 'hsj2': 'image/hsj2',
937
+ 'ief': 'image/ief',
938
+ 'jls': 'image/jls',
939
+ 'jp2': 'image/jp2',
940
+ 'jpg2': 'image/jp2',
941
+ 'jpeg': 'image/jpeg',
942
+ 'jpg': 'image/jpeg',
943
+ 'jpe': 'image/jpeg',
944
+ 'jph': 'image/jph',
945
+ 'jhc': 'image/jphc',
946
+ 'jpm': 'video/jpm',
947
+ 'jpx': 'image/jpx',
948
+ 'jpf': 'image/jpx',
949
+ 'jxr': 'image/jxr',
950
+ 'jxra': 'image/jxra',
951
+ 'jxrs': 'image/jxrs',
952
+ 'jxs': 'image/jxs',
953
+ 'jxsc': 'image/jxsc',
954
+ 'jxsi': 'image/jxsi',
955
+ 'jxss': 'image/jxss',
956
+ 'ktx': 'image/ktx',
957
+ 'ktx2': 'image/ktx2',
958
+ 'png': 'image/png',
959
+ 'btif': 'image/prs.btif',
960
+ 'pti': 'image/prs.pti',
961
+ 'sgi': 'image/sgi',
962
+ 'svg': 'image/svg+xml',
963
+ 'svgz': 'image/svg+xml',
964
+ 't38': 'image/t38',
965
+ 'tif': 'image/tiff',
966
+ 'tiff': 'image/tiff',
967
+ 'tfx': 'image/tiff-fx',
968
+ 'psd': 'image/vnd.adobe.photoshop',
969
+ 'azv': 'image/vnd.airzip.accelerator.azv',
970
+ 'uvi': 'image/vnd.dece.graphic',
971
+ 'uvvi': 'image/vnd.dece.graphic',
972
+ 'uvg': 'image/vnd.dece.graphic',
973
+ 'uvvg': 'image/vnd.dece.graphic',
974
+ 'djvu': 'image/vnd.djvu',
975
+ 'djv': 'image/vnd.djvu',
976
+ 'sub': 'text/vnd.dvb.subtitle',
977
+ 'dwg': 'image/vnd.dwg',
978
+ 'dxf': 'image/vnd.dxf',
979
+ 'fbs': 'image/vnd.fastbidsheet',
980
+ 'fpx': 'image/vnd.fpx',
981
+ 'fst': 'image/vnd.fst',
982
+ 'mmr': 'image/vnd.fujixerox.edmics-mmr',
983
+ 'rlc': 'image/vnd.fujixerox.edmics-rlc',
984
+ 'ico': 'image/x-icon',
985
+ 'dds': 'image/vnd.ms-dds',
986
+ 'mdi': 'image/vnd.ms-modi',
987
+ 'wdp': 'image/vnd.ms-photo',
988
+ 'npx': 'image/vnd.net-fpx',
989
+ 'b16': 'image/vnd.pco.b16',
990
+ 'tap': 'image/vnd.tencent.tap',
991
+ 'vtf': 'image/vnd.valve.source.texture',
992
+ 'wbmp': 'image/vnd.wap.wbmp',
993
+ 'xif': 'image/vnd.xiff',
994
+ 'pcx': 'image/x-pcx',
995
+ 'webp': 'image/webp',
996
+ '3ds': 'image/x-3ds',
997
+ 'ras': 'image/x-cmu-raster',
998
+ 'cmx': 'image/x-cmx',
999
+ 'fh': 'image/x-freehand',
1000
+ 'fhc': 'image/x-freehand',
1001
+ 'fh4': 'image/x-freehand',
1002
+ 'fh5': 'image/x-freehand',
1003
+ 'fh7': 'image/x-freehand',
1004
+ 'jng': 'image/x-jng',
1005
+ 'sid': 'image/x-mrsid-image',
1006
+ 'pic': 'image/x-pict',
1007
+ 'pct': 'image/x-pict',
1008
+ 'pnm': 'image/x-portable-anymap',
1009
+ 'pbm': 'image/x-portable-bitmap',
1010
+ 'pgm': 'image/x-portable-graymap',
1011
+ 'ppm': 'image/x-portable-pixmap',
1012
+ 'rgb': 'image/x-rgb',
1013
+ 'tga': 'image/x-tga',
1014
+ 'xbm': 'image/x-xbitmap',
1015
+ 'xpm': 'image/x-xpixmap',
1016
+ 'xwd': 'image/x-xwindowdump',
1017
+ 'disposition-notification': 'message/disposition-notification',
1018
+ 'u8msg': 'message/global',
1019
+ 'u8dsn': 'message/global-delivery-status',
1020
+ 'u8mdn': 'message/global-disposition-notification',
1021
+ 'u8hdr': 'message/global-headers',
1022
+ 'eml': 'message/rfc822',
1023
+ 'mime': 'message/rfc822',
1024
+ 'wsc': 'message/vnd.wfa.wsc',
1025
+ '3mf': 'model/3mf',
1026
+ 'gltf': 'model/gltf+json',
1027
+ 'glb': 'model/gltf-binary',
1028
+ 'igs': 'model/iges',
1029
+ 'iges': 'model/iges',
1030
+ 'msh': 'model/mesh',
1031
+ 'mesh': 'model/mesh',
1032
+ 'silo': 'model/mesh',
1033
+ 'mtl': 'model/mtl',
1034
+ 'stpx': 'model/step+xml',
1035
+ 'stpz': 'model/step+zip',
1036
+ 'stpxz': 'model/step-xml+zip',
1037
+ 'u3d': 'model/u3d',
1038
+ 'dae': 'model/vnd.collada+xml',
1039
+ 'dwf': 'model/vnd.dwf',
1040
+ 'gdl': 'model/vnd.gdl',
1041
+ 'gtw': 'model/vnd.gtw',
1042
+ 'mts': 'model/vnd.mts',
1043
+ 'ogex': 'model/vnd.opengex',
1044
+ 'x_b': 'model/vnd.parasolid.transmit.binary',
1045
+ 'x_t': 'model/vnd.parasolid.transmit.text',
1046
+ 'vds': 'model/vnd.sap.vds',
1047
+ 'usdz': 'model/vnd.usdz+zip',
1048
+ 'bsp': 'model/vnd.valve.source.compiled-map',
1049
+ 'vtu': 'model/vnd.vtu',
1050
+ 'wrl': 'model/vrml',
1051
+ 'vrml': 'model/vrml',
1052
+ 'x3db': 'model/x3d+fastinfoset',
1053
+ 'x3dbz': 'model/x3d+binary',
1054
+ 'x3dv': 'model/x3d-vrml',
1055
+ 'x3dvz': 'model/x3d+vrml',
1056
+ 'x3d': 'model/x3d+xml',
1057
+ 'x3dz': 'model/x3d+xml',
1058
+ 'appcache': 'text/cache-manifest',
1059
+ 'manifest': 'text/cache-manifest',
1060
+ 'ics': 'text/calendar',
1061
+ 'ifb': 'text/calendar',
1062
+ 'coffee': 'text/coffeescript',
1063
+ 'litcoffee': 'text/coffeescript',
1064
+ 'css': 'text/css',
1065
+ 'csv': 'text/csv',
1066
+ 'html': 'text/html',
1067
+ 'htm': 'text/html',
1068
+ 'shtml': 'text/html',
1069
+ 'jade': 'text/jade',
1070
+ 'jsx': 'text/jsx',
1071
+ 'less': 'text/less',
1072
+ 'markdown': 'text/markdown',
1073
+ 'md': 'text/markdown',
1074
+ 'mml': 'text/mathml',
1075
+ 'mdx': 'text/mdx',
1076
+ 'n3': 'text/n3',
1077
+ 'txt': 'text/plain',
1078
+ 'text': 'text/plain',
1079
+ 'conf': 'text/plain',
1080
+ 'def': 'text/plain',
1081
+ 'list': 'text/plain',
1082
+ 'log': 'text/plain',
1083
+ 'in': 'text/plain',
1084
+ 'ini': 'text/plain',
1085
+ 'dsc': 'text/prs.lines.tag',
1086
+ 'rtx': 'text/richtext',
1087
+ 'sgml': 'text/sgml',
1088
+ 'sgm': 'text/sgml',
1089
+ 'shex': 'text/shex',
1090
+ 'slim': 'text/slim',
1091
+ 'slm': 'text/slim',
1092
+ 'spdx': 'text/spdx',
1093
+ 'stylus': 'text/stylus',
1094
+ 'styl': 'text/stylus',
1095
+ 'tsv': 'text/tab-separated-values',
1096
+ 't': 'text/troff',
1097
+ 'tr': 'text/troff',
1098
+ 'roff': 'text/troff',
1099
+ 'man': 'text/troff',
1100
+ 'me': 'text/troff',
1101
+ 'ms': 'text/troff',
1102
+ 'ttl': 'text/turtle',
1103
+ 'uri': 'text/uri-list',
1104
+ 'uris': 'text/uri-list',
1105
+ 'urls': 'text/uri-list',
1106
+ 'vcard': 'text/vcard',
1107
+ 'curl': 'text/vnd.curl',
1108
+ 'dcurl': 'text/vnd.curl.dcurl',
1109
+ 'mcurl': 'text/vnd.curl.mcurl',
1110
+ 'scurl': 'text/vnd.curl.scurl',
1111
+ 'ged': 'text/vnd.familysearch.gedcom',
1112
+ 'fly': 'text/vnd.fly',
1113
+ 'flx': 'text/vnd.fmi.flexstor',
1114
+ 'gv': 'text/vnd.graphviz',
1115
+ '3dml': 'text/vnd.in3d.3dml',
1116
+ 'spot': 'text/vnd.in3d.spot',
1117
+ 'jad': 'text/vnd.sun.j2me.app-descriptor',
1118
+ 'wml': 'text/vnd.wap.wml',
1119
+ 'wmls': 'text/vnd.wap.wmlscript',
1120
+ 'vtt': 'text/vtt',
1121
+ 's': 'text/x-asm',
1122
+ 'asm': 'text/x-asm',
1123
+ 'c': 'text/x-c',
1124
+ 'cc': 'text/x-c',
1125
+ 'cxx': 'text/x-c',
1126
+ 'cpp': 'text/x-c',
1127
+ 'h': 'text/x-c',
1128
+ 'hh': 'text/x-c',
1129
+ 'dic': 'text/x-c',
1130
+ 'htc': 'text/x-component',
1131
+ 'f': 'text/x-fortran',
1132
+ 'for': 'text/x-fortran',
1133
+ 'f77': 'text/x-fortran',
1134
+ 'f90': 'text/x-fortran',
1135
+ 'hbs': 'text/x-handlebars-template',
1136
+ 'java': 'text/x-java-source',
1137
+ 'lua': 'text/x-lua',
1138
+ 'mkd': 'text/x-markdown',
1139
+ 'nfo': 'text/x-nfo',
1140
+ 'opml': 'text/x-opml',
1141
+ 'p': 'text/x-pascal',
1142
+ 'pas': 'text/x-pascal',
1143
+ 'pde': 'text/x-processing',
1144
+ 'sass': 'text/x-sass',
1145
+ 'scss': 'text/x-scss',
1146
+ 'etx': 'text/x-setext',
1147
+ 'sfv': 'text/x-sfv',
1148
+ 'ymp': 'text/x-suse-ymp',
1149
+ 'uu': 'text/x-uuencode',
1150
+ 'vcs': 'text/x-vcalendar',
1151
+ 'vcf': 'text/x-vcard',
1152
+ 'yaml': 'text/yaml',
1153
+ 'yml': 'text/yaml',
1154
+ '3gp': 'video/3gpp',
1155
+ '3g2': 'video/3gpp2',
1156
+ 'h261': 'video/h261',
1157
+ 'h263': 'video/h263',
1158
+ 'h264': 'video/h264',
1159
+ 'm4s': 'video/iso.segment',
1160
+ 'jpgv': 'video/jpeg',
1161
+ 'jpgm': 'video/jpm',
1162
+ 'mj2': 'video/mj2',
1163
+ 'mjp2': 'video/mj2',
1164
+ 'ts': 'video/mp2t',
1165
+ 'mp4': 'video/mp4',
1166
+ 'mp4v': 'video/mp4',
1167
+ 'mpg4': 'video/mp4',
1168
+ 'mpeg': 'video/mpeg',
1169
+ 'mpg': 'video/mpeg',
1170
+ 'mpe': 'video/mpeg',
1171
+ 'm1v': 'video/mpeg',
1172
+ 'm2v': 'video/mpeg',
1173
+ 'ogv': 'video/ogg',
1174
+ 'qt': 'video/quicktime',
1175
+ 'mov': 'video/quicktime',
1176
+ 'uvh': 'video/vnd.dece.hd',
1177
+ 'uvvh': 'video/vnd.dece.hd',
1178
+ 'uvm': 'video/vnd.dece.mobile',
1179
+ 'uvvm': 'video/vnd.dece.mobile',
1180
+ 'uvp': 'video/vnd.dece.pd',
1181
+ 'uvvp': 'video/vnd.dece.pd',
1182
+ 'uvs': 'video/vnd.dece.sd',
1183
+ 'uvvs': 'video/vnd.dece.sd',
1184
+ 'uvv': 'video/vnd.dece.video',
1185
+ 'uvvv': 'video/vnd.dece.video',
1186
+ 'dvb': 'video/vnd.dvb.file',
1187
+ 'fvt': 'video/vnd.fvt',
1188
+ 'mxu': 'video/vnd.mpegurl',
1189
+ 'm4u': 'video/vnd.mpegurl',
1190
+ 'pyv': 'video/vnd.ms-playready.media.pyv',
1191
+ 'uvu': 'video/vnd.uvvu.mp4',
1192
+ 'uvvu': 'video/vnd.uvvu.mp4',
1193
+ 'viv': 'video/vnd.vivo',
1194
+ 'webm': 'video/webm',
1195
+ 'f4v': 'video/x-f4v',
1196
+ 'fli': 'video/x-fli',
1197
+ 'flv': 'video/x-flv',
1198
+ 'm4v': 'video/x-m4v',
1199
+ 'mkv': 'video/x-matroska',
1200
+ 'mk3d': 'video/x-matroska',
1201
+ 'mks': 'video/x-matroska',
1202
+ 'mng': 'video/x-mng',
1203
+ 'asf': 'video/x-ms-asf',
1204
+ 'asx': 'video/x-ms-asf',
1205
+ 'vob': 'video/x-ms-vob',
1206
+ 'wm': 'video/x-ms-wm',
1207
+ 'wmv': 'video/x-ms-wmv',
1208
+ 'wmx': 'video/x-ms-wmx',
1209
+ 'wvx': 'video/x-ms-wvx',
1210
+ 'avi': 'video/x-msvideo',
1211
+ 'movie': 'video/x-sgi-movie',
1212
+ 'smv': 'video/x-smv',
1213
+ 'ice': 'x-conference/x-cooltalk',
1214
+ };
1215
+
1216
+ function getMimeType(path, fallback = null) {
1217
+ const ext = (/\.([^.]+)$/.exec(path) || [])[1] || path;
1218
+ return extensions[ext] || fallback;
1219
+ }
1220
+
1221
+ const { stat, readdir } = fs.promises;
1222
+ // export function statFile(path: string) {
1223
+ // return stat(path)
1224
+ // }
1225
+ function serveFile(filePath, options = {}) {
1226
+ return __awaiter(this, void 0, void 0, function* () {
1227
+ const { restoreCtx } = eventHttp.useHttpContext();
1228
+ const { status } = eventHttp.useResponse();
1229
+ const { setHeader, removeHeader } = eventHttp.useSetHeaders();
1230
+ const headers = eventHttp.useHeaders();
1231
+ const { method, url } = eventHttp.useRequest();
1232
+ const { setCacheControl, setExpires, setPragmaNoCache } = eventHttp.useSetCacheControl();
1233
+ const normalizedPath = path.normalize(path.join(process.cwd(), options.baseDir || '', filePath));
1234
+ let fileStats;
1235
+ try {
1236
+ fileStats = yield stat(normalizedPath);
1237
+ }
1238
+ catch (e) {
1239
+ if (options.defaultExt) {
1240
+ const ext = path.extname(filePath);
1241
+ if (!ext) {
1242
+ restoreCtx();
1243
+ return serveFile(filePath + '.' + options.defaultExt);
1244
+ }
1245
+ }
1246
+ throw new eventHttp.WooksError(404);
1247
+ }
1248
+ status(200);
1249
+ // if-none-match & if-modified-since processing start
1250
+ // rfc7232
1251
+ const etag = `"${[fileStats.ino, fileStats.size, fileStats.mtime.toISOString()].join('-')}"`;
1252
+ const lastModified = new Date(fileStats.mtime);
1253
+ if (isNotModified(etag, lastModified, headers['if-none-match'] || '', headers['if-modified-since'] || '')) {
1254
+ status(304);
1255
+ return '';
1256
+ }
1257
+ // if-none-match & if-modified-since processing end
1258
+ setHeader('etag', etag);
1259
+ setHeader('last-modified', lastModified.toUTCString());
1260
+ if (options.cacheControl !== undefined) {
1261
+ setCacheControl(options.cacheControl);
1262
+ }
1263
+ if (options.expires) {
1264
+ setExpires(options.expires);
1265
+ }
1266
+ if (options.pragmaNoCache) {
1267
+ setPragmaNoCache(options.pragmaNoCache);
1268
+ }
1269
+ if (fileStats.isDirectory()) {
1270
+ if (options.listDirectory) {
1271
+ restoreCtx();
1272
+ return listDirectory(normalizedPath);
1273
+ }
1274
+ else if (options.index) {
1275
+ if (filePath[filePath.length - 1] !== '/' && url && url[url.length - 1] !== '/') {
1276
+ return new eventHttp.BaseWooksResponse().setStatus(302).setHeader('location', url + '/');
1277
+ }
1278
+ restoreCtx();
1279
+ return serveFile(path.join(filePath, options.index), Object.assign(Object.assign({}, options), { index: '' }));
1280
+ }
1281
+ removeHeader('etag');
1282
+ removeHeader('last-modified');
1283
+ throw new eventHttp.WooksError(404);
1284
+ }
1285
+ // range header processing start
1286
+ let range = headers.range;
1287
+ let start, end;
1288
+ let size = fileStats.size;
1289
+ if (range) {
1290
+ const rangeParts = range.trim().replace(/bytes=/, '').split('-');
1291
+ const [s, e] = rangeParts;
1292
+ start = parseInt(s);
1293
+ end = e ? parseInt(e) : (size - 1);
1294
+ end = Math.min(size - 1, end);
1295
+ if (start > end || isNaN(start) || isNaN(end)) {
1296
+ throw new eventHttp.WooksError(416);
1297
+ }
1298
+ size = (end - start) + 1;
1299
+ // if-range processing start
1300
+ // rfc7233#section-3.2\
1301
+ const ifRange = headers['if-range'] || '';
1302
+ const ifRangeTag = ifRange[0] === '"' ? ifRange : '';
1303
+ const ifRangeDate = ifRangeTag ? '' : ifRange;
1304
+ if (ifRange && !isNotModified(etag, lastModified, ifRangeTag, ifRangeDate)) {
1305
+ // If the validator does not match, the server MUST ignore
1306
+ // the Range header field.
1307
+ status(200);
1308
+ size = fileStats.size;
1309
+ range = '';
1310
+ }
1311
+ else {
1312
+ // If the validator given in the If-Range header field matches the
1313
+ // current validator for the selected representation of the target
1314
+ // resource, then the server SHOULD process the Range header field as
1315
+ // requested.
1316
+ setHeader('content-range', `bytes ${start}-${end}/${fileStats.size}`);
1317
+ status(206);
1318
+ }
1319
+ // if-range processing end
1320
+ }
1321
+ // range header processing end
1322
+ setHeader('accept-ranges', 'bytes');
1323
+ setHeader('content-type', getMimeType(normalizedPath) || 'application/octet-stream');
1324
+ setHeader('content-length', size);
1325
+ if (options.headers) {
1326
+ for (const header of Object.keys(options.headers)) {
1327
+ setHeader(header, options.headers[header]);
1328
+ }
1329
+ }
1330
+ return method === 'HEAD' ? '' : fs.createReadStream(normalizedPath, !!range ? { start, end } : undefined);
1331
+ });
1332
+ }
1333
+ // function toWeak(etag: string): string {
1334
+ // return `W/${etag}`
1335
+ // }
1336
+ function isNotModified(etag, lastModified, clientEtag, clientLM) {
1337
+ if (clientEtag) {
1338
+ const parts = clientEtag.split(',').map(v => v.trim());
1339
+ for (const p of parts) {
1340
+ if (etag === p) {
1341
+ return true;
1342
+ }
1343
+ }
1344
+ // A recipient MUST ignore If-Modified-Since if the request contains an
1345
+ // If-None-Match header field; the condition in If-None-Match is
1346
+ // considered to be a more accurate replacement for the condition in
1347
+ // If-Modified-Since, and the two are only combined for the sake of
1348
+ // interoperating with older intermediaries that might not implement
1349
+ // If-None-Match.
1350
+ return false;
1351
+ }
1352
+ const date = new Date(clientLM);
1353
+ // A recipient MUST ignore the If-Modified-Since header field if the
1354
+ // received field-value is not a valid HTTP-date, or if the request
1355
+ // method is neither GET nor HEAD.
1356
+ if (date.toString() !== 'Invalid Date' && date.getTime() > lastModified.getTime()) {
1357
+ return true;
1358
+ }
1359
+ return false;
1360
+ }
1361
+ function listDirectory(dirPath) {
1362
+ return __awaiter(this, void 0, void 0, function* () {
1363
+ const { setContentType } = eventHttp.useSetHeaders();
1364
+ const { url } = eventHttp.useRequest();
1365
+ const list = yield readdir(dirPath);
1366
+ const promises = [];
1367
+ let detailedList = [];
1368
+ for (const item of list) {
1369
+ promises.push({ name: item, promise: stat(path.join(dirPath, item)) });
1370
+ }
1371
+ for (const item of promises) {
1372
+ const data = yield item.promise;
1373
+ detailedList.push({
1374
+ name: item.name, size: data.size, mtime: data.mtime, dir: data.isDirectory(),
1375
+ });
1376
+ }
1377
+ detailedList = detailedList.sort((a, b) => a.dir === b.dir ? a.name > b.name ? 1 : -1 : a.dir > b.dir ? -1 : 1);
1378
+ detailedList.unshift({ name: '..', dir: true });
1379
+ setContentType('text/html');
1380
+ const styles = '<style type="text/css">\nhtml { font-family: monospace }\n' +
1381
+ 'span { padding: 0px 2px }\n' +
1382
+ '.text { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }\n' +
1383
+ '.icon { width: 20px; display: inline-block; text-align: center; }\n' +
1384
+ '.name { width: 250px; display: inline-block; }\n' +
1385
+ '.size { width: 80px; display: inline-block; color: grey; text-align: right; }\n' +
1386
+ '.date { width: 200px; display: inline-block; color: grey; text-align: right; }\n' +
1387
+ '\n</style>';
1388
+ return '<html><head><title>Dir</title> ' + styles + ' </head><body><ul>' +
1389
+ detailedList.map(d => `<li> <span class="icon">${d.dir ? '&#128193;' : '&#128462;'}</span>` +
1390
+ `<a href="${path.join(url || '', d.name)}"><span class="name text">${d.name}</span></a>` +
1391
+ `<span class="size text">${d.size && (d.size > 10000 ? (Math.round(d.size / 1024 / 1024).toString() + 'Mb') : (Math.round(d.size / 1024).toString() + 'Kb')) || ''}</span>` +
1392
+ `<span class="date text">${d.mtime && d.mtime.toISOString() || ''}</li>`).join('\n') +
1393
+ '</ul></body></html>';
1394
+ });
1395
+ }
1396
+
1397
+ exports.serveFile = serveFile;