Updated README.rdoc again
[feedcatcher.git] / vendor / rails / actionpack / lib / action_controller / vendor / rack-1.0 / rack / mime.rb
1 module Rack
2 module Mime
3 # Returns String with mime type if found, otherwise use +fallback+.
4 # +ext+ should be filename extension in the '.ext' format that
5 # File.extname(file) returns.
6 # +fallback+ may be any object
7 #
8 # Also see the documentation for MIME_TYPES
9 #
10 # Usage:
11 # Rack::Mime.mime_type('.foo')
12 #
13 # This is a shortcut for:
14 # Rack::Mime::MIME_TYPES.fetch('.foo', 'application/octet-stream')
15
16 def mime_type(ext, fallback='application/octet-stream')
17 MIME_TYPES.fetch(ext, fallback)
18 end
19 module_function :mime_type
20
21 # List of most common mime-types, selected various sources
22 # according to their usefulness in a webserving scope for Ruby
23 # users.
24 #
25 # To amend this list with your local mime.types list you can use:
26 #
27 # require 'webrick/httputils'
28 # list = WEBrick::HTTPUtils.load_mime_types('/etc/mime.types')
29 # Rack::Mime::MIME_TYPES.merge!(list)
30 #
31 # To add the list mongrel provides, use:
32 #
33 # require 'mongrel/handlers'
34 # Rack::Mime::MIME_TYPES.merge!(Mongrel::DirHandler::MIME_TYPES)
35
36 MIME_TYPES = {
37 ".3gp" => "video/3gpp",
38 ".a" => "application/octet-stream",
39 ".ai" => "application/postscript",
40 ".aif" => "audio/x-aiff",
41 ".aiff" => "audio/x-aiff",
42 ".asc" => "application/pgp-signature",
43 ".asf" => "video/x-ms-asf",
44 ".asm" => "text/x-asm",
45 ".asx" => "video/x-ms-asf",
46 ".atom" => "application/atom+xml",
47 ".au" => "audio/basic",
48 ".avi" => "video/x-msvideo",
49 ".bat" => "application/x-msdownload",
50 ".bin" => "application/octet-stream",
51 ".bmp" => "image/bmp",
52 ".bz2" => "application/x-bzip2",
53 ".c" => "text/x-c",
54 ".cab" => "application/vnd.ms-cab-compressed",
55 ".cc" => "text/x-c",
56 ".chm" => "application/vnd.ms-htmlhelp",
57 ".class" => "application/octet-stream",
58 ".com" => "application/x-msdownload",
59 ".conf" => "text/plain",
60 ".cpp" => "text/x-c",
61 ".crt" => "application/x-x509-ca-cert",
62 ".css" => "text/css",
63 ".csv" => "text/csv",
64 ".cxx" => "text/x-c",
65 ".deb" => "application/x-debian-package",
66 ".der" => "application/x-x509-ca-cert",
67 ".diff" => "text/x-diff",
68 ".djv" => "image/vnd.djvu",
69 ".djvu" => "image/vnd.djvu",
70 ".dll" => "application/x-msdownload",
71 ".dmg" => "application/octet-stream",
72 ".doc" => "application/msword",
73 ".dot" => "application/msword",
74 ".dtd" => "application/xml-dtd",
75 ".dvi" => "application/x-dvi",
76 ".ear" => "application/java-archive",
77 ".eml" => "message/rfc822",
78 ".eps" => "application/postscript",
79 ".exe" => "application/x-msdownload",
80 ".f" => "text/x-fortran",
81 ".f77" => "text/x-fortran",
82 ".f90" => "text/x-fortran",
83 ".flv" => "video/x-flv",
84 ".for" => "text/x-fortran",
85 ".gem" => "application/octet-stream",
86 ".gemspec" => "text/x-script.ruby",
87 ".gif" => "image/gif",
88 ".gz" => "application/x-gzip",
89 ".h" => "text/x-c",
90 ".hh" => "text/x-c",
91 ".htm" => "text/html",
92 ".html" => "text/html",
93 ".ico" => "image/vnd.microsoft.icon",
94 ".ics" => "text/calendar",
95 ".ifb" => "text/calendar",
96 ".iso" => "application/octet-stream",
97 ".jar" => "application/java-archive",
98 ".java" => "text/x-java-source",
99 ".jnlp" => "application/x-java-jnlp-file",
100 ".jpeg" => "image/jpeg",
101 ".jpg" => "image/jpeg",
102 ".js" => "application/javascript",
103 ".json" => "application/json",
104 ".log" => "text/plain",
105 ".m3u" => "audio/x-mpegurl",
106 ".m4v" => "video/mp4",
107 ".man" => "text/troff",
108 ".mathml" => "application/mathml+xml",
109 ".mbox" => "application/mbox",
110 ".mdoc" => "text/troff",
111 ".me" => "text/troff",
112 ".mid" => "audio/midi",
113 ".midi" => "audio/midi",
114 ".mime" => "message/rfc822",
115 ".mml" => "application/mathml+xml",
116 ".mng" => "video/x-mng",
117 ".mov" => "video/quicktime",
118 ".mp3" => "audio/mpeg",
119 ".mp4" => "video/mp4",
120 ".mp4v" => "video/mp4",
121 ".mpeg" => "video/mpeg",
122 ".mpg" => "video/mpeg",
123 ".ms" => "text/troff",
124 ".msi" => "application/x-msdownload",
125 ".odp" => "application/vnd.oasis.opendocument.presentation",
126 ".ods" => "application/vnd.oasis.opendocument.spreadsheet",
127 ".odt" => "application/vnd.oasis.opendocument.text",
128 ".ogg" => "application/ogg",
129 ".p" => "text/x-pascal",
130 ".pas" => "text/x-pascal",
131 ".pbm" => "image/x-portable-bitmap",
132 ".pdf" => "application/pdf",
133 ".pem" => "application/x-x509-ca-cert",
134 ".pgm" => "image/x-portable-graymap",
135 ".pgp" => "application/pgp-encrypted",
136 ".pkg" => "application/octet-stream",
137 ".pl" => "text/x-script.perl",
138 ".pm" => "text/x-script.perl-module",
139 ".png" => "image/png",
140 ".pnm" => "image/x-portable-anymap",
141 ".ppm" => "image/x-portable-pixmap",
142 ".pps" => "application/vnd.ms-powerpoint",
143 ".ppt" => "application/vnd.ms-powerpoint",
144 ".ps" => "application/postscript",
145 ".psd" => "image/vnd.adobe.photoshop",
146 ".py" => "text/x-script.python",
147 ".qt" => "video/quicktime",
148 ".ra" => "audio/x-pn-realaudio",
149 ".rake" => "text/x-script.ruby",
150 ".ram" => "audio/x-pn-realaudio",
151 ".rar" => "application/x-rar-compressed",
152 ".rb" => "text/x-script.ruby",
153 ".rdf" => "application/rdf+xml",
154 ".roff" => "text/troff",
155 ".rpm" => "application/x-redhat-package-manager",
156 ".rss" => "application/rss+xml",
157 ".rtf" => "application/rtf",
158 ".ru" => "text/x-script.ruby",
159 ".s" => "text/x-asm",
160 ".sgm" => "text/sgml",
161 ".sgml" => "text/sgml",
162 ".sh" => "application/x-sh",
163 ".sig" => "application/pgp-signature",
164 ".snd" => "audio/basic",
165 ".so" => "application/octet-stream",
166 ".svg" => "image/svg+xml",
167 ".svgz" => "image/svg+xml",
168 ".swf" => "application/x-shockwave-flash",
169 ".t" => "text/troff",
170 ".tar" => "application/x-tar",
171 ".tbz" => "application/x-bzip-compressed-tar",
172 ".tcl" => "application/x-tcl",
173 ".tex" => "application/x-tex",
174 ".texi" => "application/x-texinfo",
175 ".texinfo" => "application/x-texinfo",
176 ".text" => "text/plain",
177 ".tif" => "image/tiff",
178 ".tiff" => "image/tiff",
179 ".torrent" => "application/x-bittorrent",
180 ".tr" => "text/troff",
181 ".txt" => "text/plain",
182 ".vcf" => "text/x-vcard",
183 ".vcs" => "text/x-vcalendar",
184 ".vrml" => "model/vrml",
185 ".war" => "application/java-archive",
186 ".wav" => "audio/x-wav",
187 ".wma" => "audio/x-ms-wma",
188 ".wmv" => "video/x-ms-wmv",
189 ".wmx" => "video/x-ms-wmx",
190 ".wrl" => "model/vrml",
191 ".wsdl" => "application/wsdl+xml",
192 ".xbm" => "image/x-xbitmap",
193 ".xhtml" => "application/xhtml+xml",
194 ".xls" => "application/vnd.ms-excel",
195 ".xml" => "application/xml",
196 ".xpm" => "image/x-xpixmap",
197 ".xsl" => "application/xml",
198 ".xslt" => "application/xslt+xml",
199 ".yaml" => "text/yaml",
200 ".yml" => "text/yaml",
201 ".zip" => "application/zip",
202 }
203 end
204 end