Issues (15)

src/Middleware/ServerStaticMiddleware.php (1 issue)

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

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1045
            return MiddlewareResult::/** @scrutinizer ignore-call */ stopProcessingOthers(HtmlOutputProcessor::class);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
1046
        }
1047
1048
        return MiddlewareResult::continue();
1049
    }
1050
1051
    /**
1052
     * Get the Mime Type based on the filename
1053
     *
1054
     * @param string $filename
1055
     * @return string
1056
     */
1057 6
    public function mimeContentType($filename)
1058
    {
1059 6
        if (!file_exists($filename)) {
1060 1
            return null;
1061
        }
1062
1063 5
        $prohibitedTypes = [
1064 5
            "php",
1065 5
            "vb",
1066 5
            "cs",
1067 5
            "rb",
1068 5
            "py",
1069 5
            "py3",
1070 5
            "lua"
1071 5
        ];
1072
1073 5
        $ext = substr(strrchr($filename, "."), 1);
1074 5
        if (in_array($ext, $prohibitedTypes)) {
1075 1
            throw new Error415Exception("File type not supported");
1076
        }
1077
1078 4
        if (!function_exists('finfo_open')) {
1079
            throw new Error500Exception("ServerStaticMiddleware requires finfo extension");
1080
        }
1081
1082 4
        return $this->getContentType($filename);
1083
    }
1084
1085 4
    private function getContentType($filename)
1086
    {
1087
        // get the file extension
1088 4
        $ext = substr(strrchr($filename, "."), 1);
1089
1090
        // check if the extension is in the list of known extensions else return the generic mime type
1091 4
        if (array_key_exists($ext, $this->mimeTypes)) {
1092 4
            return $this->mimeTypes[$ext];
1093
        } else {
1094
            return 'application/octet-stream';
1095
        }
1096
    }
1097
1098
}
1099