| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Plack::MIME; |
|
2
|
11
|
|
|
11
|
|
837
|
use strict; |
|
|
11
|
|
|
|
|
29
|
|
|
|
11
|
|
|
|
|
7379
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# stolen from rack.mime.rb |
|
5
|
|
|
|
|
|
|
our $MIME_TYPES = { |
|
6
|
|
|
|
|
|
|
".3gp" => "video/3gpp", |
|
7
|
|
|
|
|
|
|
".a" => "application/octet-stream", |
|
8
|
|
|
|
|
|
|
".ai" => "application/postscript", |
|
9
|
|
|
|
|
|
|
".aif" => "audio/x-aiff", |
|
10
|
|
|
|
|
|
|
".aiff" => "audio/x-aiff", |
|
11
|
|
|
|
|
|
|
".apk" => "application/vnd.android.package-archive", |
|
12
|
|
|
|
|
|
|
".asc" => "application/pgp-signature", |
|
13
|
|
|
|
|
|
|
".asf" => "video/x-ms-asf", |
|
14
|
|
|
|
|
|
|
".asm" => "text/x-asm", |
|
15
|
|
|
|
|
|
|
".asx" => "video/x-ms-asf", |
|
16
|
|
|
|
|
|
|
".atom" => "application/atom+xml", |
|
17
|
|
|
|
|
|
|
".au" => "audio/basic", |
|
18
|
|
|
|
|
|
|
".avi" => "video/x-msvideo", |
|
19
|
|
|
|
|
|
|
".bat" => "application/x-msdownload", |
|
20
|
|
|
|
|
|
|
".bin" => "application/octet-stream", |
|
21
|
|
|
|
|
|
|
".bmp" => "image/bmp", |
|
22
|
|
|
|
|
|
|
".bz2" => "application/x-bzip2", |
|
23
|
|
|
|
|
|
|
".c" => "text/x-c", |
|
24
|
|
|
|
|
|
|
".cab" => "application/vnd.ms-cab-compressed", |
|
25
|
|
|
|
|
|
|
".cc" => "text/x-c", |
|
26
|
|
|
|
|
|
|
".chm" => "application/vnd.ms-htmlhelp", |
|
27
|
|
|
|
|
|
|
".class" => "application/octet-stream", |
|
28
|
|
|
|
|
|
|
".com" => "application/x-msdownload", |
|
29
|
|
|
|
|
|
|
".conf" => "text/plain", |
|
30
|
|
|
|
|
|
|
".cpp" => "text/x-c", |
|
31
|
|
|
|
|
|
|
".crt" => "application/x-x509-ca-cert", |
|
32
|
|
|
|
|
|
|
".css" => "text/css", |
|
33
|
|
|
|
|
|
|
".csv" => "text/csv", |
|
34
|
|
|
|
|
|
|
".cxx" => "text/x-c", |
|
35
|
|
|
|
|
|
|
".deb" => "application/x-debian-package", |
|
36
|
|
|
|
|
|
|
".der" => "application/x-x509-ca-cert", |
|
37
|
|
|
|
|
|
|
".diff" => "text/x-diff", |
|
38
|
|
|
|
|
|
|
".djv" => "image/vnd.djvu", |
|
39
|
|
|
|
|
|
|
".djvu" => "image/vnd.djvu", |
|
40
|
|
|
|
|
|
|
".dll" => "application/x-msdownload", |
|
41
|
|
|
|
|
|
|
".dmg" => "application/octet-stream", |
|
42
|
|
|
|
|
|
|
".doc" => "application/msword", |
|
43
|
|
|
|
|
|
|
".dot" => "application/msword", |
|
44
|
|
|
|
|
|
|
".dtd" => "application/xml-dtd", |
|
45
|
|
|
|
|
|
|
".dvi" => "application/x-dvi", |
|
46
|
|
|
|
|
|
|
".ear" => "application/java-archive", |
|
47
|
|
|
|
|
|
|
".eml" => "message/rfc822", |
|
48
|
|
|
|
|
|
|
".eps" => "application/postscript", |
|
49
|
|
|
|
|
|
|
".exe" => "application/x-msdownload", |
|
50
|
|
|
|
|
|
|
".f" => "text/x-fortran", |
|
51
|
|
|
|
|
|
|
".f77" => "text/x-fortran", |
|
52
|
|
|
|
|
|
|
".f90" => "text/x-fortran", |
|
53
|
|
|
|
|
|
|
".flv" => "video/x-flv", |
|
54
|
|
|
|
|
|
|
".for" => "text/x-fortran", |
|
55
|
|
|
|
|
|
|
".gem" => "application/octet-stream", |
|
56
|
|
|
|
|
|
|
".gemspec" => "text/x-script.ruby", |
|
57
|
|
|
|
|
|
|
".gif" => "image/gif", |
|
58
|
|
|
|
|
|
|
".gz" => "application/x-gzip", |
|
59
|
|
|
|
|
|
|
".h" => "text/x-c", |
|
60
|
|
|
|
|
|
|
".hh" => "text/x-c", |
|
61
|
|
|
|
|
|
|
".htm" => "text/html", |
|
62
|
|
|
|
|
|
|
".html" => "text/html", |
|
63
|
|
|
|
|
|
|
".ico" => "image/vnd.microsoft.icon", |
|
64
|
|
|
|
|
|
|
".ics" => "text/calendar", |
|
65
|
|
|
|
|
|
|
".ifb" => "text/calendar", |
|
66
|
|
|
|
|
|
|
".iso" => "application/octet-stream", |
|
67
|
|
|
|
|
|
|
".jar" => "application/java-archive", |
|
68
|
|
|
|
|
|
|
".java" => "text/x-java-source", |
|
69
|
|
|
|
|
|
|
".jnlp" => "application/x-java-jnlp-file", |
|
70
|
|
|
|
|
|
|
".jpeg" => "image/jpeg", |
|
71
|
|
|
|
|
|
|
".jpg" => "image/jpeg", |
|
72
|
|
|
|
|
|
|
".js" => "application/javascript", |
|
73
|
|
|
|
|
|
|
".json" => "application/json", |
|
74
|
|
|
|
|
|
|
".log" => "text/plain", |
|
75
|
|
|
|
|
|
|
".m3u" => "audio/x-mpegurl", |
|
76
|
|
|
|
|
|
|
".m4v" => "video/mp4", |
|
77
|
|
|
|
|
|
|
".man" => "text/troff", |
|
78
|
|
|
|
|
|
|
".manifest"=> "text/cache-manifest", |
|
79
|
|
|
|
|
|
|
".mathml" => "application/mathml+xml", |
|
80
|
|
|
|
|
|
|
".mbox" => "application/mbox", |
|
81
|
|
|
|
|
|
|
".mdoc" => "text/troff", |
|
82
|
|
|
|
|
|
|
".me" => "text/troff", |
|
83
|
|
|
|
|
|
|
".mid" => "audio/midi", |
|
84
|
|
|
|
|
|
|
".midi" => "audio/midi", |
|
85
|
|
|
|
|
|
|
".mime" => "message/rfc822", |
|
86
|
|
|
|
|
|
|
".mml" => "application/mathml+xml", |
|
87
|
|
|
|
|
|
|
".mng" => "video/x-mng", |
|
88
|
|
|
|
|
|
|
".mov" => "video/quicktime", |
|
89
|
|
|
|
|
|
|
".mp3" => "audio/mpeg", |
|
90
|
|
|
|
|
|
|
".mp4" => "video/mp4", |
|
91
|
|
|
|
|
|
|
".mp4v" => "video/mp4", |
|
92
|
|
|
|
|
|
|
".mpeg" => "video/mpeg", |
|
93
|
|
|
|
|
|
|
".mpg" => "video/mpeg", |
|
94
|
|
|
|
|
|
|
".ms" => "text/troff", |
|
95
|
|
|
|
|
|
|
".msi" => "application/x-msdownload", |
|
96
|
|
|
|
|
|
|
".odp" => "application/vnd.oasis.opendocument.presentation", |
|
97
|
|
|
|
|
|
|
".ods" => "application/vnd.oasis.opendocument.spreadsheet", |
|
98
|
|
|
|
|
|
|
".odt" => "application/vnd.oasis.opendocument.text", |
|
99
|
|
|
|
|
|
|
".ogg" => "application/ogg", |
|
100
|
|
|
|
|
|
|
".ogv" => "video/ogg", |
|
101
|
|
|
|
|
|
|
".p" => "text/x-pascal", |
|
102
|
|
|
|
|
|
|
".pas" => "text/x-pascal", |
|
103
|
|
|
|
|
|
|
".pbm" => "image/x-portable-bitmap", |
|
104
|
|
|
|
|
|
|
".pdf" => "application/pdf", |
|
105
|
|
|
|
|
|
|
".pem" => "application/x-x509-ca-cert", |
|
106
|
|
|
|
|
|
|
".pgm" => "image/x-portable-graymap", |
|
107
|
|
|
|
|
|
|
".pgp" => "application/pgp-encrypted", |
|
108
|
|
|
|
|
|
|
".pkg" => "application/octet-stream", |
|
109
|
|
|
|
|
|
|
".pl" => "text/x-script.perl", |
|
110
|
|
|
|
|
|
|
".pm" => "text/x-script.perl-module", |
|
111
|
|
|
|
|
|
|
".png" => "image/png", |
|
112
|
|
|
|
|
|
|
".pnm" => "image/x-portable-anymap", |
|
113
|
|
|
|
|
|
|
".ppm" => "image/x-portable-pixmap", |
|
114
|
|
|
|
|
|
|
".pps" => "application/vnd.ms-powerpoint", |
|
115
|
|
|
|
|
|
|
".ppt" => "application/vnd.ms-powerpoint", |
|
116
|
|
|
|
|
|
|
".ps" => "application/postscript", |
|
117
|
|
|
|
|
|
|
".psd" => "image/vnd.adobe.photoshop", |
|
118
|
|
|
|
|
|
|
".py" => "text/x-script.python", |
|
119
|
|
|
|
|
|
|
".qt" => "video/quicktime", |
|
120
|
|
|
|
|
|
|
".ra" => "audio/x-pn-realaudio", |
|
121
|
|
|
|
|
|
|
".rake" => "text/x-script.ruby", |
|
122
|
|
|
|
|
|
|
".ram" => "audio/x-pn-realaudio", |
|
123
|
|
|
|
|
|
|
".rar" => "application/x-rar-compressed", |
|
124
|
|
|
|
|
|
|
".rb" => "text/x-script.ruby", |
|
125
|
|
|
|
|
|
|
".rdf" => "application/rdf+xml", |
|
126
|
|
|
|
|
|
|
".roff" => "text/troff", |
|
127
|
|
|
|
|
|
|
".rpm" => "application/x-redhat-package-manager", |
|
128
|
|
|
|
|
|
|
".rss" => "application/rss+xml", |
|
129
|
|
|
|
|
|
|
".rtf" => "application/rtf", |
|
130
|
|
|
|
|
|
|
".ru" => "text/x-script.ruby", |
|
131
|
|
|
|
|
|
|
".s" => "text/x-asm", |
|
132
|
|
|
|
|
|
|
".sgm" => "text/sgml", |
|
133
|
|
|
|
|
|
|
".sgml" => "text/sgml", |
|
134
|
|
|
|
|
|
|
".sh" => "application/x-sh", |
|
135
|
|
|
|
|
|
|
".sig" => "application/pgp-signature", |
|
136
|
|
|
|
|
|
|
".snd" => "audio/basic", |
|
137
|
|
|
|
|
|
|
".so" => "application/octet-stream", |
|
138
|
|
|
|
|
|
|
".svg" => "image/svg+xml", |
|
139
|
|
|
|
|
|
|
".svgz" => "image/svg+xml", |
|
140
|
|
|
|
|
|
|
".swf" => "application/x-shockwave-flash", |
|
141
|
|
|
|
|
|
|
".t" => "text/troff", |
|
142
|
|
|
|
|
|
|
".tar" => "application/x-tar", |
|
143
|
|
|
|
|
|
|
".tbz" => "application/x-bzip-compressed-tar", |
|
144
|
|
|
|
|
|
|
".tcl" => "application/x-tcl", |
|
145
|
|
|
|
|
|
|
".tex" => "application/x-tex", |
|
146
|
|
|
|
|
|
|
".texi" => "application/x-texinfo", |
|
147
|
|
|
|
|
|
|
".texinfo" => "application/x-texinfo", |
|
148
|
|
|
|
|
|
|
".text" => "text/plain", |
|
149
|
|
|
|
|
|
|
".tif" => "image/tiff", |
|
150
|
|
|
|
|
|
|
".tiff" => "image/tiff", |
|
151
|
|
|
|
|
|
|
".torrent" => "application/x-bittorrent", |
|
152
|
|
|
|
|
|
|
".tr" => "text/troff", |
|
153
|
|
|
|
|
|
|
".ttf" => "font/ttf", |
|
154
|
|
|
|
|
|
|
".txt" => "text/plain", |
|
155
|
|
|
|
|
|
|
".vcf" => "text/x-vcard", |
|
156
|
|
|
|
|
|
|
".vcs" => "text/x-vcalendar", |
|
157
|
|
|
|
|
|
|
".vrml" => "model/vrml", |
|
158
|
|
|
|
|
|
|
".war" => "application/java-archive", |
|
159
|
|
|
|
|
|
|
".wav" => "audio/x-wav", |
|
160
|
|
|
|
|
|
|
".webm" => "video/webm", |
|
161
|
|
|
|
|
|
|
".webp" => "image/webp", |
|
162
|
|
|
|
|
|
|
".wma" => "audio/x-ms-wma", |
|
163
|
|
|
|
|
|
|
".wmv" => "video/x-ms-wmv", |
|
164
|
|
|
|
|
|
|
".wmx" => "video/x-ms-wmx", |
|
165
|
|
|
|
|
|
|
".woff" => "application/font-woff", |
|
166
|
|
|
|
|
|
|
".wrl" => "model/vrml", |
|
167
|
|
|
|
|
|
|
".wsdl" => "application/wsdl+xml", |
|
168
|
|
|
|
|
|
|
".xbm" => "image/x-xbitmap", |
|
169
|
|
|
|
|
|
|
".xhtml" => "application/xhtml+xml", |
|
170
|
|
|
|
|
|
|
".xls" => "application/vnd.ms-excel", |
|
171
|
|
|
|
|
|
|
".xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", |
|
172
|
|
|
|
|
|
|
".xml" => "application/xml", |
|
173
|
|
|
|
|
|
|
".xpm" => "image/x-xpixmap", |
|
174
|
|
|
|
|
|
|
".xsl" => "application/xml", |
|
175
|
|
|
|
|
|
|
".xslt" => "application/xslt+xml", |
|
176
|
|
|
|
|
|
|
".yaml" => "text/yaml", |
|
177
|
|
|
|
|
|
|
".yml" => "text/yaml", |
|
178
|
|
|
|
|
|
|
".zip" => "application/zip", |
|
179
|
|
|
|
|
|
|
}; |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
my $fallback = sub { }; |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub mime_type { |
|
184
|
30
|
|
|
30
|
0
|
178
|
my($class, $file) = @_; |
|
185
|
30
|
100
|
|
|
|
239
|
$file =~ /(\.[a-zA-Z0-9\-]+)$/ or return; |
|
186
|
26
|
100
|
|
|
|
292
|
$MIME_TYPES->{lc $1} || $fallback->(lc $1); |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub add_type { |
|
190
|
4
|
|
|
4
|
0
|
3927
|
my $class = shift; |
|
191
|
4
|
|
|
|
|
65
|
while (my($ext, $type) = splice @_, 0, 2) { |
|
192
|
4
|
|
|
|
|
41
|
$MIME_TYPES->{lc $ext} = $type; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub set_fallback { |
|
197
|
0
|
|
|
0
|
0
|
|
my($class, $cb) = @_; |
|
198
|
0
|
|
|
|
|
|
$fallback = $cb; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
1; |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
__END__ |