swiftiply 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTORS +2 -0
- data/README +1 -1
- data/bin/echo_client +26 -0
- data/bin/swiftiply +21 -8
- data/ext/fastfilereader/extconf.rb +161 -0
- data/ext/fastfilereader/mapper.cpp +200 -0
- data/ext/fastfilereader/mapper.h +59 -0
- data/ext/fastfilereader/rubymain.cpp +127 -0
- data/external/test_support.rb +13 -0
- data/setup.rb +7 -2
- data/src/fastfilereader.rb +109 -0
- data/src/swiftcore/Swiftiply.rb +432 -103
- data/src/swiftcore/Swiftiply/support_pagecache.rb +56 -0
- data/src/swiftcore/Swiftiply/swiftiply_client.rb +57 -0
- data/src/swiftcore/evented_mongrel.rb +32 -4
- data/src/swiftcore/swiftiplied_mongrel.rb +50 -38
- data/src/swiftcore/types.rb +1583 -0
- data/swiftiply.gemspec +4 -4
- data/test/TC_ProxyBag.rb +185 -0
- data/test/TC_Swiftiply.rb +458 -0
- data/test/TC_Swiftiply/mongrel/evented_hello.rb +25 -0
- data/test/TC_Swiftiply/mongrel/swiftiplied_hello.rb +25 -0
- data/test/TC_Swiftiply/mongrel/threaded_hello.rb +25 -0
- data/test/TC_Swiftiply/slow_echo_client +26 -0
- metadata +34 -121
- data/src/ramaze/adapter/evented_mongrel.rb +0 -2
- data/src/ramaze/adapter/swiftiplied_mongrel.rb +0 -2
- data/test/rails/README +0 -182
- data/test/rails/Rakefile +0 -10
- data/test/rails/app/controllers/application.rb +0 -6
- data/test/rails/app/controllers/tests_controller.rb +0 -15
- data/test/rails/app/helpers/application_helper.rb +0 -3
- data/test/rails/config/boot.rb +0 -45
- data/test/rails/config/database.yml +0 -36
- data/test/rails/config/environment.rb +0 -60
- data/test/rails/config/environments/development.rb +0 -21
- data/test/rails/config/environments/production.rb +0 -18
- data/test/rails/config/environments/production_no_caching.rb +0 -18
- data/test/rails/config/environments/test.rb +0 -19
- data/test/rails/config/routes.rb +0 -23
- data/test/rails/doc/README_FOR_APP +0 -2
- data/test/rails/observe_ram.rb +0 -10
- data/test/rails/public/404.html +0 -30
- data/test/rails/public/500.html +0 -30
- data/test/rails/public/dispatch.cgi +0 -10
- data/test/rails/public/dispatch.fcgi +0 -24
- data/test/rails/public/dispatch.rb +0 -10
- data/test/rails/public/favicon.ico +0 -0
- data/test/rails/public/images/rails.png +0 -0
- data/test/rails/public/index.html +0 -277
- data/test/rails/public/javascripts/application.js +0 -2
- data/test/rails/public/javascripts/controls.js +0 -833
- data/test/rails/public/javascripts/dragdrop.js +0 -942
- data/test/rails/public/javascripts/effects.js +0 -1088
- data/test/rails/public/javascripts/prototype.js +0 -2515
- data/test/rails/public/robots.txt +0 -1
- data/test/rails/script/about +0 -3
- data/test/rails/script/breakpointer +0 -3
- data/test/rails/script/console +0 -3
- data/test/rails/script/destroy +0 -3
- data/test/rails/script/generate +0 -3
- data/test/rails/script/performance/benchmarker +0 -3
- data/test/rails/script/performance/profiler +0 -3
- data/test/rails/script/plugin +0 -3
- data/test/rails/script/process/inspector +0 -3
- data/test/rails/script/process/reaper +0 -3
- data/test/rails/script/process/spawner +0 -3
- data/test/rails/script/runner +0 -3
- data/test/rails/script/server +0 -3
- data/test/rails/test/test_helper.rb +0 -28
- data/test/ramaze/conf/benchmark.yaml +0 -35
- data/test/ramaze/conf/debug.yaml +0 -34
- data/test/ramaze/conf/live.yaml +0 -33
- data/test/ramaze/conf/silent.yaml +0 -31
- data/test/ramaze/conf/stage.yaml +0 -33
- data/test/ramaze/main.rb +0 -18
- data/test/ramaze/public/404.jpg +0 -0
- data/test/ramaze/public/css/coderay.css +0 -105
- data/test/ramaze/public/css/ramaze_error.css +0 -42
- data/test/ramaze/public/error.zmr +0 -77
- data/test/ramaze/public/favicon.ico +0 -0
- data/test/ramaze/public/js/jquery.js +0 -1923
- data/test/ramaze/public/ramaze.png +0 -0
- data/test/ramaze/src/controller/main.rb +0 -8
- data/test/ramaze/src/element/page.rb +0 -17
- data/test/ramaze/src/model.rb +0 -6
- data/test/ramaze/template/index.xhtml +0 -6
- data/test/ramaze/yaml.db +0 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- coding: ISO-8859-1 -*-
|
2
|
+
|
3
|
+
# support_pagecache will be required by Swiftiply, as necessary, in order to
|
4
|
+
# enable support for Rails style page caching. The caching implementation is
|
5
|
+
# flexible, using /public/ as the cache directory by default, but allowing that
|
6
|
+
# default to be overridden, and looking for .html files by default, but also
|
7
|
+
# allowing that to be overridden.
|
8
|
+
|
9
|
+
module Swiftcore
|
10
|
+
module Swiftiply
|
11
|
+
class ProxyBag
|
12
|
+
DefaultCacheDir = 'public'.freeze
|
13
|
+
DefaultSuffixes = ['html'.freeze]
|
14
|
+
@suffix_list = {}
|
15
|
+
@cache_dir = {}
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def add_suffix_list(list,name)
|
19
|
+
@suffix_list[name] = list
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove_suffix_list(list,name)
|
23
|
+
@suffix_list.delete name
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_cache_dir(dir,name)
|
27
|
+
@cache_dir[name] = dir
|
28
|
+
end
|
29
|
+
|
30
|
+
def remove_cache_dir(name)
|
31
|
+
@cache_dir.delete name
|
32
|
+
end
|
33
|
+
|
34
|
+
def find_static_file(dr,path_info,client_name)
|
35
|
+
path = File.join(dr,path_info)
|
36
|
+
if FileTest.exist?(path) and FileTest.file?(path)
|
37
|
+
path
|
38
|
+
elsif @suffix_list.has_key?(client_name)
|
39
|
+
path = File.join(dr,@cache_dir[client_name],path_info)
|
40
|
+
if FileTest.exist?(path) and FileTest.file?(path)
|
41
|
+
path
|
42
|
+
else
|
43
|
+
for suffix in @suffix_list[client_name] do
|
44
|
+
p = "#{path}.#{suffix}"
|
45
|
+
return p if FileTest.exist?(p) and FileTest.file?(p)
|
46
|
+
end
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
else
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# -*- coding: ISO-8859-1 -*-
|
2
|
+
require 'eventmachine'
|
3
|
+
require 'socket'
|
4
|
+
|
5
|
+
# This is a basic Swiftiply client implementation.
|
6
|
+
|
7
|
+
class SwiftiplyClientProtocol < EventMachine::Connection
|
8
|
+
|
9
|
+
attr_accessor :hostname, :port, :key, :ip, :id
|
10
|
+
|
11
|
+
C_dotdotdot = '...'.freeze
|
12
|
+
C0s = [0,0,0,0].freeze
|
13
|
+
CCCCC = 'CCCC'.freeze
|
14
|
+
CContentLength = 'Content-Length'.freeze
|
15
|
+
DefaultHeaders = {'Connection' => 'close', 'Content-Type' => 'text/plain'}
|
16
|
+
|
17
|
+
def self.connect(hostname = nil,port = nil,key = '')
|
18
|
+
key = key.to_s
|
19
|
+
|
20
|
+
connection = ::EventMachine.connect(hostname, port, self) do |conn|
|
21
|
+
conn.hostname = hostname
|
22
|
+
conn.port = port
|
23
|
+
conn.key = key
|
24
|
+
ip = conn.ip = conn.__get_ip(hostname)
|
25
|
+
conn.id = 'swiftclient' << ip.collect {|x| sprintf('%02x',x.to_i)}.join << sprintf('%04x',port.to_i)<< sprintf('%02x',key.length) << key
|
26
|
+
conn.set_comm_inactivity_timeout inactivity_timeout
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.inactivity_timeout
|
31
|
+
@inactivity_timeout || 60
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.inactivity_timeout=(val)
|
35
|
+
@inactivity_timeout = val
|
36
|
+
end
|
37
|
+
|
38
|
+
def connection_completed
|
39
|
+
send_data @id
|
40
|
+
end
|
41
|
+
|
42
|
+
def unbind
|
43
|
+
::EventMachine.add_timer(rand(2)) {self.class.connect(@hostname,@port,@key)}
|
44
|
+
end
|
45
|
+
|
46
|
+
def send_http_data(data,h = {},status = 200, msg = C_dotdotdot)
|
47
|
+
headers = DefaultHeaders.merge(h)
|
48
|
+
headers[CContentLength] = data.length
|
49
|
+
header_string = ''
|
50
|
+
headers.each {|k,v| header_string << "#{k}: #{v}\r\n"}
|
51
|
+
send_data("HTTP/1.1 #{status} #{msg}\r\n#{header_string}\r\n#{data}")
|
52
|
+
end
|
53
|
+
|
54
|
+
def __get_ip hostname
|
55
|
+
Socket.gethostbyname(hostname)[3].unpack(CCCCC) rescue ip = C0s
|
56
|
+
end
|
57
|
+
end
|
@@ -126,10 +126,7 @@ module Mongrel
|
|
126
126
|
response = HttpResponse.new(client)
|
127
127
|
|
128
128
|
# Process each handler in registered order until we run out or one finalizes the response.
|
129
|
-
handlers
|
130
|
-
handler.process(request, response)
|
131
|
-
break if response.done
|
132
|
-
end
|
129
|
+
dispatch_to_handlers(handlers,request,response)
|
133
130
|
|
134
131
|
# And finally, if nobody closed the response off, we finalize it.
|
135
132
|
unless response.done
|
@@ -143,6 +140,13 @@ module Mongrel
|
|
143
140
|
client.close_connection_after_writing
|
144
141
|
end
|
145
142
|
end
|
143
|
+
|
144
|
+
def dispatch_to_handlers(handlers,request,response)
|
145
|
+
handlers.each do |handler|
|
146
|
+
handler.process(request, response)
|
147
|
+
break if response.done
|
148
|
+
end
|
149
|
+
end
|
146
150
|
end
|
147
151
|
|
148
152
|
class HttpRequest
|
@@ -188,4 +192,28 @@ module Mongrel
|
|
188
192
|
@socket.close_connection_after_writing
|
189
193
|
end
|
190
194
|
end
|
195
|
+
|
196
|
+
class Configurator
|
197
|
+
# This version fixes a bug in the regular Mongrel version by adding
|
198
|
+
# initialization of groups.
|
199
|
+
def change_privilege(user, group)
|
200
|
+
if user and group
|
201
|
+
log "Initializing groups for {#user}:{#group}."
|
202
|
+
Process.initgroups(user,Etc.getgrnam(group).gid)
|
203
|
+
end
|
204
|
+
|
205
|
+
if group
|
206
|
+
log "Changing group to #{group}."
|
207
|
+
Process::GID.change_privilege(Etc.getgrnam(group).gid)
|
208
|
+
end
|
209
|
+
|
210
|
+
if user
|
211
|
+
log "Changing user to #{user}."
|
212
|
+
Process::UID.change_privilege(Etc.getpwnam(user).uid)
|
213
|
+
end
|
214
|
+
rescue Errno::EPERM
|
215
|
+
log "FAILED to change user:group #{user}:#{group}: #$!"
|
216
|
+
exit 1
|
217
|
+
end
|
218
|
+
end
|
191
219
|
end
|
@@ -7,6 +7,8 @@
|
|
7
7
|
begin
|
8
8
|
load_attempted ||= false
|
9
9
|
require 'eventmachine'
|
10
|
+
require 'swiftcore/Swiftiply/swiftiply_client'
|
11
|
+
require 'mongrel'
|
10
12
|
rescue LoadError
|
11
13
|
unless load_attempted
|
12
14
|
load_attempted = true
|
@@ -15,30 +17,11 @@ rescue LoadError
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
require 'mongrel'
|
19
|
-
|
20
20
|
module Mongrel
|
21
|
-
|
22
|
-
|
23
|
-
@hostname ||= hostname
|
24
|
-
@port ||= port
|
25
|
-
|
26
|
-
::EventMachine.connect(@hostname, @port, self) do |conn|
|
27
|
-
conn.set_comm_inactivity_timeout 60
|
28
|
-
end
|
29
|
-
end
|
21
|
+
C0s = [0,0,0,0].freeze unless const_defined?(:C0s)
|
22
|
+
CCCCC = 'CCCC'.freeze unless const_defined?(:CCCCC)
|
30
23
|
|
31
|
-
|
32
|
-
@hostname
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.port
|
36
|
-
@port
|
37
|
-
end
|
38
|
-
|
39
|
-
def connection_completed
|
40
|
-
@completed = true
|
41
|
-
end
|
24
|
+
class MongrelProtocol < SwiftiplyClientProtocol
|
42
25
|
|
43
26
|
def post_init
|
44
27
|
@parser = HttpParser.new
|
@@ -49,14 +32,6 @@ module Mongrel
|
|
49
32
|
@linebuffer = ''
|
50
33
|
end
|
51
34
|
|
52
|
-
def unbind
|
53
|
-
if @completed
|
54
|
-
self.class.connect
|
55
|
-
else
|
56
|
-
::EventMachine.add_timer(rand(4)) {self.class.connect}
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
35
|
def receive_data data
|
61
36
|
@linebuffer << data
|
62
37
|
@nparsed = @parser.execute(@params, @linebuffer, @nparsed) unless @parser.finished?
|
@@ -112,11 +87,19 @@ module Mongrel
|
|
112
87
|
end
|
113
88
|
|
114
89
|
class HttpServer
|
115
|
-
|
90
|
+
# There is no framework agnostic way to get that key value from the
|
91
|
+
# configuration into here; it'll require code specific to the way the
|
92
|
+
# different frameworks handle their configuration of Mongrel. So....
|
93
|
+
# The support is here, for swiftiplied_mongrels which are secured by
|
94
|
+
# a key. If someone want to donate any patches. Otherwise, this won't
|
95
|
+
# really be useful to most people until 0.7.0.
|
96
|
+
|
97
|
+
def initialize(host, port, num_processors=(2**30-1), timeout=0,key = '')
|
116
98
|
@socket = nil
|
117
99
|
@classifier = URIClassifier.new
|
118
100
|
@host = host
|
119
101
|
@port = port
|
102
|
+
@key = key
|
120
103
|
@workers = ThreadGroup.new
|
121
104
|
@timeout = timeout
|
122
105
|
@num_processors = num_processors
|
@@ -125,12 +108,12 @@ module Mongrel
|
|
125
108
|
end
|
126
109
|
|
127
110
|
def run
|
128
|
-
trap('INT') {
|
129
|
-
trap('TERM') {
|
111
|
+
trap('INT') { EventMachine.stop_event_loop }
|
112
|
+
trap('TERM') { EventMachine.stop_event_loop }
|
130
113
|
@acceptor = Thread.new do
|
131
114
|
EventMachine.run do
|
132
115
|
begin
|
133
|
-
|
116
|
+
MongrelProtocol.connect(@host,@port,@key)
|
134
117
|
rescue StopServer
|
135
118
|
EventMachine.stop_event_loop
|
136
119
|
end
|
@@ -156,10 +139,7 @@ module Mongrel
|
|
156
139
|
response = HttpResponse.new(client)
|
157
140
|
|
158
141
|
# Process each handler in registered order until we run out or one finalizes the response.
|
159
|
-
handlers
|
160
|
-
handler.process(request, response)
|
161
|
-
break if response.done
|
162
|
-
end
|
142
|
+
dispatch_to_handlers(handlers,request,response)
|
163
143
|
|
164
144
|
# And finally, if nobody closed the response off, we finalize it.
|
165
145
|
unless response.done
|
@@ -176,6 +156,14 @@ module Mongrel
|
|
176
156
|
response.finished
|
177
157
|
end
|
178
158
|
end
|
159
|
+
|
160
|
+
def dispatch_to_handlers(handlers,request,response)
|
161
|
+
handlers.each do |handler|
|
162
|
+
handler.process(request, response)
|
163
|
+
break if response.done
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
179
167
|
end
|
180
168
|
|
181
169
|
class HttpRequest
|
@@ -216,4 +204,28 @@ module Mongrel
|
|
216
204
|
send_body
|
217
205
|
end
|
218
206
|
end
|
207
|
+
|
208
|
+
class Configurator
|
209
|
+
# This version fixes a bug in the regular Mongrel version by adding
|
210
|
+
# initialization of groups.
|
211
|
+
def change_privilege(user, group)
|
212
|
+
if user and group
|
213
|
+
log "Initializing groups for {#user}:{#group}."
|
214
|
+
Process.initgroups(user,Etc.getgrnam(group).gid)
|
215
|
+
end
|
216
|
+
|
217
|
+
if group
|
218
|
+
log "Changing group to #{group}."
|
219
|
+
Process::GID.change_privilege(Etc.getgrnam(group).gid)
|
220
|
+
end
|
221
|
+
|
222
|
+
if user
|
223
|
+
log "Changing user to #{user}."
|
224
|
+
Process::UID.change_privilege(Etc.getpwnam(user).uid)
|
225
|
+
end
|
226
|
+
rescue Errno::EPERM
|
227
|
+
log "FAILED to change user:group #{user}:#{group}: #$!"
|
228
|
+
exit 1
|
229
|
+
end
|
230
|
+
end
|
219
231
|
end
|
@@ -0,0 +1,1583 @@
|
|
1
|
+
#--
|
2
|
+
# MIME::Types for Ruby
|
3
|
+
# Version 1.15sc1
|
4
|
+
#
|
5
|
+
# This version of MIME::Types has been optimized for Swiftcore by Kirk Haines.
|
6
|
+
#
|
7
|
+
# Copyright (c) 2002 - 2004 Austin Ziegler
|
8
|
+
#
|
9
|
+
# $Id: types.rb,v 1.4 2006/02/12 21:27:22 austin Exp $
|
10
|
+
#
|
11
|
+
#++
|
12
|
+
|
13
|
+
# The namespace for MIME applications, tools, and libraries.
|
14
|
+
module MIME
|
15
|
+
# Reflects a MIME Content-Type which is in invalid format (e.g., it isn't
|
16
|
+
# in the form of type/subtype).
|
17
|
+
class InvalidContentType < RuntimeError; end
|
18
|
+
|
19
|
+
# The definition of one MIME content-type.
|
20
|
+
#
|
21
|
+
# == Usage
|
22
|
+
# require 'mime/types'
|
23
|
+
#
|
24
|
+
# plaintext = MIME::Types['text/plain']
|
25
|
+
# print plaintext.media_type # => 'text'
|
26
|
+
# print plaintext.sub_type # => 'plain'
|
27
|
+
#
|
28
|
+
# puts plaintext.extensions.join(" ") # => 'asc txt c cc h hh cpp'
|
29
|
+
#
|
30
|
+
# puts plaintext.encoding # => 8bit
|
31
|
+
# puts plaintext.binary? # => false
|
32
|
+
# puts plaintext.ascii? # => true
|
33
|
+
# puts plaintext == 'text/plain' # => true
|
34
|
+
# puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
|
35
|
+
#
|
36
|
+
class Type
|
37
|
+
VERSION = '1.15sc1'
|
38
|
+
|
39
|
+
include Comparable
|
40
|
+
|
41
|
+
MEDIA_TYPE_RE = %r{([-\w.+]+)/([-\w.+]*)}o #:nodoc:
|
42
|
+
UNREG_RE = %r{[Xx]-}o #:nodoc:
|
43
|
+
ENCODING_RE = %r{(?:base64|7bit|8bit|quoted\-printable)}o #:nodoc:
|
44
|
+
PLATFORM_RE = %r|#{RUBY_PLATFORM}|o #:nodoc:
|
45
|
+
|
46
|
+
SIGNATURES = %w(application/pgp-keys application/pgp
|
47
|
+
application/pgp-signature application/pkcs10
|
48
|
+
application/pkcs7-mime application/pkcs7-signature
|
49
|
+
text/vcard) #:nodoc:
|
50
|
+
|
51
|
+
IANA_URL = "http://www.iana.org/assignments/media-types/%s/%s"
|
52
|
+
RFC_URL = "http://rfc-editor.org/rfc/rfc%s.txt"
|
53
|
+
DRAFT_URL = "http://datatracker.ietf.org/public/idindex.cgi?command=id_details&filename=%s"
|
54
|
+
LTSW_URL = "http://www.ltsw.se/knbase/internet/%s.htp"
|
55
|
+
CONTACT_URL = "http://www.iana.org/assignments/contact-people.htm#%s"
|
56
|
+
|
57
|
+
# Returns +true+ if the simplified type matches the current
|
58
|
+
def like?(other)
|
59
|
+
if other.respond_to?(:simplified)
|
60
|
+
@simplified == other.simplified
|
61
|
+
else
|
62
|
+
@simplified == Type.simplified(other)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Compares the MIME::Type against the exact content type or the
|
67
|
+
# simplified type (the simplified type will be used if comparing against
|
68
|
+
# something that can be treated as a String with #to_s).
|
69
|
+
def <=>(other) #:nodoc:
|
70
|
+
if other.respond_to?(:content_type)
|
71
|
+
@content_type.downcase <=> other.content_type.downcase
|
72
|
+
elsif other.respond_to?(:to_s)
|
73
|
+
@simplified <=> Type.simplified(other.to_s)
|
74
|
+
else
|
75
|
+
@content_type.downcase <=> other.downcase
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Returns +true+ if the other object is a MIME::Type and the content
|
80
|
+
# types match.
|
81
|
+
def eql?(other) #:nodoc:
|
82
|
+
other.kind_of?(MIME::Type) and self == other
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns the whole MIME content-type string.
|
86
|
+
#
|
87
|
+
# text/plain => text/plain
|
88
|
+
# x-chemical/x-pdb => x-chemical/x-pdb
|
89
|
+
attr_reader :content_type
|
90
|
+
# Returns the media type of the simplified MIME type.
|
91
|
+
#
|
92
|
+
# text/plain => text
|
93
|
+
# x-chemical/x-pdb => chemical
|
94
|
+
attr_reader :media_type
|
95
|
+
# Returns the media type of the unmodified MIME type.
|
96
|
+
#
|
97
|
+
# text/plain => text
|
98
|
+
# x-chemical/x-pdb => x-chemical
|
99
|
+
attr_reader :raw_media_type
|
100
|
+
# Returns the sub-type of the simplified MIME type.
|
101
|
+
#
|
102
|
+
# text/plain => plain
|
103
|
+
# x-chemical/x-pdb => pdb
|
104
|
+
attr_reader :sub_type
|
105
|
+
# Returns the media type of the unmodified MIME type.
|
106
|
+
#
|
107
|
+
# text/plain => plain
|
108
|
+
# x-chemical/x-pdb => x-pdb
|
109
|
+
attr_reader :raw_sub_type
|
110
|
+
# The MIME types main- and sub-label can both start with <tt>x-</tt>,
|
111
|
+
# which indicates that it is a non-registered name. Of course, after
|
112
|
+
# registration this flag can disappear, adds to the confusing
|
113
|
+
# proliferation of MIME types. The simplified string has the <tt>x-</tt>
|
114
|
+
# removed and are translated to lowercase.
|
115
|
+
#
|
116
|
+
# text/plain => text/plain
|
117
|
+
# x-chemical/x-pdb => chemical/pdb
|
118
|
+
attr_reader :simplified
|
119
|
+
# The list of extensions which are known to be used for this MIME::Type.
|
120
|
+
# Non-array values will be coerced into an array with #to_a. Array
|
121
|
+
# values will be flattened and +nil+ values removed.
|
122
|
+
attr_accessor :extensions
|
123
|
+
remove_method :extensions= ;
|
124
|
+
def extensions=(ext) #:nodoc:
|
125
|
+
@extensions = ext.to_a.flatten.compact
|
126
|
+
end
|
127
|
+
|
128
|
+
# The encoding (7bit, 8bit, quoted-printable, or base64) required to
|
129
|
+
# transport the data of this content type safely across a network, which
|
130
|
+
# roughly corresponds to Content-Transfer-Encoding. A value of +nil+ or
|
131
|
+
# <tt>:default</tt> will reset the #encoding to the #default_encoding
|
132
|
+
# for the MIME::Type. Raises ArgumentError if the encoding provided is
|
133
|
+
# invalid.
|
134
|
+
#
|
135
|
+
# If the encoding is not provided on construction, this will be either
|
136
|
+
# 'quoted-printable' (for text/* media types) and 'base64' for eveything
|
137
|
+
# else.
|
138
|
+
attr_accessor :encoding
|
139
|
+
remove_method :encoding= ;
|
140
|
+
def encoding=(enc) #:nodoc:
|
141
|
+
if enc.nil? or enc == :default
|
142
|
+
@encoding = self.default_encoding
|
143
|
+
elsif enc =~ ENCODING_RE
|
144
|
+
@encoding = enc
|
145
|
+
else
|
146
|
+
raise ArgumentError, "The encoding must be nil, :default, base64, 7bit, 8bit, or quoted-printable."
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# The regexp for the operating system that this MIME::Type is specific
|
151
|
+
# to.
|
152
|
+
attr_accessor :system
|
153
|
+
remove_method :system= ;
|
154
|
+
def system=(os) #:nodoc:
|
155
|
+
if os.nil? or os.kind_of?(Regexp)
|
156
|
+
@system = os
|
157
|
+
else
|
158
|
+
@system = %r|#{os}|
|
159
|
+
end
|
160
|
+
end
|
161
|
+
# Returns the default encoding for the MIME::Type based on the media
|
162
|
+
# type.
|
163
|
+
attr_reader :default_encoding
|
164
|
+
remove_method :default_encoding
|
165
|
+
def default_encoding
|
166
|
+
(@media_type == 'text') ? 'quoted-printable' : 'base64'
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns the media type or types that should be used instead of this
|
170
|
+
# media type, if it is obsolete. If there is no replacement media type,
|
171
|
+
# or it is not obsolete, +nil+ will be returned.
|
172
|
+
attr_reader :use_instead
|
173
|
+
remove_method :use_instead
|
174
|
+
def use_instead
|
175
|
+
return nil unless @obsolete
|
176
|
+
@use_instead
|
177
|
+
end
|
178
|
+
|
179
|
+
# Returns +true+ if the media type is obsolete.
|
180
|
+
def obsolete?
|
181
|
+
@obsolete ? true : false
|
182
|
+
end
|
183
|
+
# Sets the obsolescence indicator for this media type.
|
184
|
+
attr_writer :obsolete
|
185
|
+
|
186
|
+
# The documentation for this MIME::Type. Documentation about media
|
187
|
+
# types will be found on a media type definition as a comment.
|
188
|
+
# Documentation will be found through #docs.
|
189
|
+
attr_accessor :docs
|
190
|
+
remove_method :docs= ;
|
191
|
+
def docs=(d)
|
192
|
+
if d
|
193
|
+
a = d.scan(%r{use-instead:#{MEDIA_TYPE_RE}})
|
194
|
+
|
195
|
+
if a.empty?
|
196
|
+
@use_instead = nil
|
197
|
+
else
|
198
|
+
@use_instead = a.map { |el| "#{el[0]}/#{el[1]}" }
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# The encoded URL list for this MIME::Type. See #urls for
|
204
|
+
attr_accessor :url
|
205
|
+
# The decoded URL list for this MIME::Type.
|
206
|
+
# The special URL value IANA will be translated into:
|
207
|
+
# http://www.iana.org/assignments/media-types/<mediatype>/<subtype>
|
208
|
+
#
|
209
|
+
# The special URL value RFC### will be translated into:
|
210
|
+
# http://www.rfc-editor.org/rfc/rfc###.txt
|
211
|
+
#
|
212
|
+
# The special URL value DRAFT:name will be translated into:
|
213
|
+
# https://datatracker.ietf.org/public/idindex.cgi?
|
214
|
+
# command=id_detail&filename=<name>
|
215
|
+
#
|
216
|
+
# The special URL value LTSW will be translated into:
|
217
|
+
# http://www.ltsw.se/knbase/internet/<mediatype>.htp
|
218
|
+
#
|
219
|
+
# The special URL value [token] will be translated into:
|
220
|
+
# http://www.iana.org/assignments/contact-people.htm#<token>
|
221
|
+
#
|
222
|
+
# These values will be accessible through #url, which always returns an
|
223
|
+
# array.
|
224
|
+
def urls
|
225
|
+
@url.map { |el|
|
226
|
+
case el
|
227
|
+
when %r{^IANA$}
|
228
|
+
IANA_URL % [ @media_type, @sub_type ]
|
229
|
+
when %r{^RFC(\d+)$}
|
230
|
+
RFC_URL % $1
|
231
|
+
when %r{^DRAFT:(.+)$}
|
232
|
+
DRAFT_URL % $1
|
233
|
+
when %r{^LTSW$}
|
234
|
+
LTSW_URL % @media_type
|
235
|
+
when %r{^\[([^\]]+)\]}
|
236
|
+
CONTACT_URL % $1
|
237
|
+
else
|
238
|
+
el
|
239
|
+
end
|
240
|
+
}
|
241
|
+
end
|
242
|
+
|
243
|
+
class << self
|
244
|
+
# The MIME types main- and sub-label can both start with <tt>x-</tt>,
|
245
|
+
# which indicates that it is a non-registered name. Of course, after
|
246
|
+
# registration this flag can disappear, adds to the confusing
|
247
|
+
# proliferation of MIME types. The simplified string has the
|
248
|
+
# <tt>x-</tt> removed and are translated to lowercase.
|
249
|
+
def simplified(content_type)
|
250
|
+
matchdata = MEDIA_TYPE_RE.match(content_type)
|
251
|
+
|
252
|
+
if matchdata.nil?
|
253
|
+
simplified = nil
|
254
|
+
else
|
255
|
+
media_type = matchdata.captures[0].downcase.gsub(UNREG_RE, '')
|
256
|
+
subtype = matchdata.captures[1].downcase.gsub(UNREG_RE, '')
|
257
|
+
simplified = "#{media_type}/#{subtype}"
|
258
|
+
end
|
259
|
+
simplified
|
260
|
+
end
|
261
|
+
|
262
|
+
# Creates a MIME::Type from an array in the form of:
|
263
|
+
# [type-name, [extensions], encoding, system]
|
264
|
+
#
|
265
|
+
# +extensions+, +encoding+, and +system+ are optional.
|
266
|
+
#
|
267
|
+
# MIME::Type.from_array("application/x-ruby", ['rb'], '8bit')
|
268
|
+
# MIME::Type.from_array(["application/x-ruby", ['rb'], '8bit'])
|
269
|
+
#
|
270
|
+
# These are equivalent to:
|
271
|
+
#
|
272
|
+
# MIME::Type.new('application/x-ruby') do |t|
|
273
|
+
# t.extensions = %w(rb)
|
274
|
+
# t.encoding = '8bit'
|
275
|
+
# end
|
276
|
+
def from_array(*args) #:yields MIME::Type.new:
|
277
|
+
# Dereferences the array one level, if necessary.
|
278
|
+
args = args[0] if args[0].kind_of?(Array)
|
279
|
+
|
280
|
+
if args.size.between?(1, 8)
|
281
|
+
m = MIME::Type.new(args[0]) do |t|
|
282
|
+
t.extensions = args[1] if args.size > 1
|
283
|
+
t.encoding = args[2] if args.size > 2
|
284
|
+
t.system = args[3] if args.size > 3
|
285
|
+
t.obsolete = args[4] if args.size > 4
|
286
|
+
t.docs = args[5] if args.size > 5
|
287
|
+
t.url = args[6] if args.size > 6
|
288
|
+
t.registered = args[7] if args.size > 7
|
289
|
+
end
|
290
|
+
yield m if block_given?
|
291
|
+
else
|
292
|
+
raise ArgumentError, "Array provided must contain between one and eight elements."
|
293
|
+
end
|
294
|
+
m
|
295
|
+
end
|
296
|
+
|
297
|
+
# Creates a MIME::Type from a hash. Keys are case-insensitive,
|
298
|
+
# dashes may be replaced with underscores, and the internal Symbol
|
299
|
+
# of the lowercase-underscore version can be used as well. That is,
|
300
|
+
# Content-Type can be provided as content-type, Content_Type,
|
301
|
+
# content_type, or :content_type.
|
302
|
+
#
|
303
|
+
# Known keys are <tt>Content-Type</tt>,
|
304
|
+
# <tt>Content-Transfer-Encoding</tt>, <tt>Extensions</tt>, and
|
305
|
+
# <tt>System</tt>.
|
306
|
+
#
|
307
|
+
# MIME::Type.from_hash('Content-Type' => 'text/x-yaml',
|
308
|
+
# 'Content-Transfer-Encoding' => '8bit',
|
309
|
+
# 'System' => 'linux',
|
310
|
+
# 'Extensions' => ['yaml', 'yml'])
|
311
|
+
#
|
312
|
+
# This is equivalent to:
|
313
|
+
#
|
314
|
+
# MIME::Type.new('text/x-yaml') do |t|
|
315
|
+
# t.encoding = '8bit'
|
316
|
+
# t.system = 'linux'
|
317
|
+
# t.extensions = ['yaml', 'yml']
|
318
|
+
# end
|
319
|
+
def from_hash(hash) #:yields MIME::Type.new:
|
320
|
+
type = {}
|
321
|
+
hash.each_pair do |k, v|
|
322
|
+
type[k.to_s.tr('-A-Z', '_a-z').to_sym] = v
|
323
|
+
end
|
324
|
+
|
325
|
+
m = MIME::Type.new(type[:content_type]) do |t|
|
326
|
+
t.extensions = type[:extensions]
|
327
|
+
t.encoding = type[:content_transfer_encoding]
|
328
|
+
t.system = type[:system]
|
329
|
+
t.obsolete = type[:obsolete]
|
330
|
+
t.docs = type[:docs]
|
331
|
+
t.url = type[:url]
|
332
|
+
t.registered = type[:registered]
|
333
|
+
end
|
334
|
+
|
335
|
+
yield m if block_given?
|
336
|
+
m
|
337
|
+
end
|
338
|
+
|
339
|
+
# Essentially a copy constructor.
|
340
|
+
#
|
341
|
+
# MIME::Type.from_mime_type(plaintext)
|
342
|
+
#
|
343
|
+
# is equivalent to:
|
344
|
+
#
|
345
|
+
# MIME::Type.new(plaintext.content_type.dup) do |t|
|
346
|
+
# t.extensions = plaintext.extensions.dup
|
347
|
+
# t.system = plaintext.system.dup
|
348
|
+
# t.encoding = plaintext.encoding.dup
|
349
|
+
# end
|
350
|
+
def from_mime_type(mime_type) #:yields the new MIME::Type:
|
351
|
+
m = MIME::Type.new(mime_type.content_type.dup) do |t|
|
352
|
+
t.extensions = mime_type.extensions.dup
|
353
|
+
t.system = mime_type.system.dup
|
354
|
+
t.encoding = mime_type.encoding.dup
|
355
|
+
end
|
356
|
+
|
357
|
+
yield m if block_given?
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
# Builds a MIME::Type object from the provided MIME Content Type value
|
362
|
+
# (e.g., 'text/plain' or 'applicaton/x-eruby'). The constructed object
|
363
|
+
# is yielded to an optional block for additional configuration, such as
|
364
|
+
# associating extensions and encoding information.
|
365
|
+
def initialize(content_type) #:yields self:
|
366
|
+
matchdata = MEDIA_TYPE_RE.match(content_type)
|
367
|
+
|
368
|
+
if matchdata.nil?
|
369
|
+
raise InvalidContentType, "Invalid Content-Type provided ('#{content_type}')"
|
370
|
+
end
|
371
|
+
|
372
|
+
@content_type = content_type
|
373
|
+
@raw_media_type = matchdata.captures[0]
|
374
|
+
@raw_sub_type = matchdata.captures[1]
|
375
|
+
|
376
|
+
@simplified = MIME::Type.simplified(@content_type)
|
377
|
+
matchdata = MEDIA_TYPE_RE.match(@simplified)
|
378
|
+
@media_type = matchdata.captures[0]
|
379
|
+
@sub_type = matchdata.captures[1]
|
380
|
+
|
381
|
+
self.extensions = nil
|
382
|
+
self.encoding = :default
|
383
|
+
self.system = nil
|
384
|
+
self.registered = true
|
385
|
+
|
386
|
+
yield self if block_given?
|
387
|
+
end
|
388
|
+
|
389
|
+
# MIME content-types which are not regestered by IANA nor defined in
|
390
|
+
# RFCs are required to start with <tt>x-</tt>. This counts as well for
|
391
|
+
# a new media type as well as a new sub-type of an existing media
|
392
|
+
# type. If either the media-type or the content-type begins with
|
393
|
+
# <tt>x-</tt>, this method will return +false+.
|
394
|
+
def registered?
|
395
|
+
if (@raw_media_type =~ UNREG_RE) || (@raw_sub_type =~ UNREG_RE)
|
396
|
+
false
|
397
|
+
else
|
398
|
+
@registered
|
399
|
+
end
|
400
|
+
end
|
401
|
+
attr_writer :registered #:nodoc:
|
402
|
+
|
403
|
+
# MIME types can be specified to be sent across a network in particular
|
404
|
+
# formats. This method returns +true+ when the MIME type encoding is set
|
405
|
+
# to <tt>base64</tt>.
|
406
|
+
def binary?
|
407
|
+
@encoding == 'base64'
|
408
|
+
end
|
409
|
+
|
410
|
+
# MIME types can be specified to be sent across a network in particular
|
411
|
+
# formats. This method returns +false+ when the MIME type encoding is
|
412
|
+
# set to <tt>base64</tt>.
|
413
|
+
def ascii?
|
414
|
+
not binary?
|
415
|
+
end
|
416
|
+
|
417
|
+
# Returns +true+ when the simplified MIME type is in the list of known
|
418
|
+
# digital signatures.
|
419
|
+
def signature?
|
420
|
+
SIGNATURES.include?(@simplified.downcase)
|
421
|
+
end
|
422
|
+
|
423
|
+
# Returns +true+ if the MIME::Type is specific to an operating system.
|
424
|
+
def system?
|
425
|
+
not @system.nil?
|
426
|
+
end
|
427
|
+
|
428
|
+
# Returns +true+ if the MIME::Type is specific to the current operating
|
429
|
+
# system as represented by RUBY_PLATFORM.
|
430
|
+
def platform?
|
431
|
+
system? and (RUBY_PLATFORM =~ @system)
|
432
|
+
end
|
433
|
+
|
434
|
+
# Returns +true+ if the MIME::Type specifies an extension list,
|
435
|
+
# indicating that it is a complete MIME::Type.
|
436
|
+
def complete?
|
437
|
+
not @extensions.empty?
|
438
|
+
end
|
439
|
+
|
440
|
+
# Returns the MIME type as a string.
|
441
|
+
def to_s
|
442
|
+
@content_type
|
443
|
+
end
|
444
|
+
|
445
|
+
# Returns the MIME type as a string for implicit conversions.
|
446
|
+
def to_str
|
447
|
+
@content_type
|
448
|
+
end
|
449
|
+
|
450
|
+
# Returns the MIME type as an array suitable for use with
|
451
|
+
# MIME::Type.from_array.
|
452
|
+
def to_a
|
453
|
+
[ @content_type, @extensions, @encoding, @system, @obsolete, @docs,
|
454
|
+
@url, registered? ]
|
455
|
+
end
|
456
|
+
|
457
|
+
# Returns the MIME type as an array suitable for use with
|
458
|
+
# MIME::Type.from_hash.
|
459
|
+
def to_hash
|
460
|
+
{ 'Content-Type' => @content_type,
|
461
|
+
'Content-Transfer-Encoding' => @encoding,
|
462
|
+
'Extensions' => @extensions,
|
463
|
+
'System' => @system,
|
464
|
+
'Obsolete' => @obsolete,
|
465
|
+
'Docs' => @docs,
|
466
|
+
'URL' => @url,
|
467
|
+
'Registered' => registered?,
|
468
|
+
}
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
# = MIME::Types
|
473
|
+
# MIME types are used in MIME-compliant communications, as in e-mail or
|
474
|
+
# HTTP traffic, to indicate the type of content which is transmitted.
|
475
|
+
# MIME::Types provides the ability for detailed information about MIME
|
476
|
+
# entities (provided as a set of MIME::Type objects) to be determined and
|
477
|
+
# used programmatically. There are many types defined by RFCs and vendors,
|
478
|
+
# so the list is long but not complete; don't hesitate to ask to add
|
479
|
+
# additional information. This library follows the IANA collection of MIME
|
480
|
+
# types (see below for reference).
|
481
|
+
#
|
482
|
+
# == Description
|
483
|
+
# MIME types are used in MIME entities, as in email or HTTP traffic. It is
|
484
|
+
# useful at times to have information available about MIME types (or,
|
485
|
+
# inversely, about files). A MIME::Type stores the known information about
|
486
|
+
# one MIME type.
|
487
|
+
#
|
488
|
+
# == Usage
|
489
|
+
# require 'mime/types'
|
490
|
+
#
|
491
|
+
# plaintext = MIME::Types['text/plain']
|
492
|
+
# print plaintext.media_type # => 'text'
|
493
|
+
# print plaintext.sub_type # => 'plain'
|
494
|
+
#
|
495
|
+
# puts plaintext.extensions.join(" ") # => 'asc txt c cc h hh cpp'
|
496
|
+
#
|
497
|
+
# puts plaintext.encoding # => 8bit
|
498
|
+
# puts plaintext.binary? # => false
|
499
|
+
# puts plaintext.ascii? # => true
|
500
|
+
# puts plaintext.obsolete? # => false
|
501
|
+
# puts plaintext.registered? # => true
|
502
|
+
# puts plaintext == 'text/plain' # => true
|
503
|
+
# puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
|
504
|
+
#
|
505
|
+
# This module is built to conform to the MIME types of RFCs 2045 and 2231.
|
506
|
+
# It follows the official IANA registry at
|
507
|
+
# http://www.iana.org/assignments/media-types/ and
|
508
|
+
# ftp://ftp.iana.org/assignments/media-types with some unofficial types
|
509
|
+
# added from the the collection at
|
510
|
+
# http://www.ltsw.se/knbase/internet/mime.htp
|
511
|
+
#
|
512
|
+
# This is originally based on Perl MIME::Types by Mark Overmeer.
|
513
|
+
#
|
514
|
+
# = Author
|
515
|
+
# Copyright:: Copyright (c) 2002 - 2006 by Austin Ziegler
|
516
|
+
# <austin@rubyforge.org>
|
517
|
+
# Version:: 1.15
|
518
|
+
# Based On:: Perl
|
519
|
+
# MIME::Types[http://search.cpan.org/author/MARKOV/MIME-Types-1.15/MIME/Types.pm],
|
520
|
+
# Copyright (c) 2001 - 2005 by Mark Overmeer
|
521
|
+
# <mimetypes@overmeer.net>.
|
522
|
+
# Licence:: Ruby's, Perl Artistic, or GPL version 2 (or later)
|
523
|
+
# See Also:: http://www.iana.org/assignments/media-types/
|
524
|
+
# http://www.ltsw.se/knbase/internet/mime.htp
|
525
|
+
#
|
526
|
+
class Types
|
527
|
+
Cdot = '.'.freeze
|
528
|
+
|
529
|
+
# The released version of Ruby MIME::Types
|
530
|
+
VERSION = '1.15'
|
531
|
+
|
532
|
+
# The data version.
|
533
|
+
attr_reader :data_version
|
534
|
+
|
535
|
+
def initialize(data_version = nil)
|
536
|
+
@type_variants = Hash.new { |h, k| h[k] = [] }
|
537
|
+
@extension_index = Hash.new { |h, k| h[k] = [] }
|
538
|
+
@simplified_index = {}
|
539
|
+
end
|
540
|
+
|
541
|
+
def add_type_variant(mime_type) #:nodoc:
|
542
|
+
@type_variants[mime_type.simplified] << mime_type
|
543
|
+
end
|
544
|
+
|
545
|
+
def index_extensions(mime_type) #:nodoc:
|
546
|
+
mime_type.extensions.each { |ext| @extension_index[ext] << mime_type }
|
547
|
+
end
|
548
|
+
|
549
|
+
def simplified_extensions(mime_type) #:nodoc:
|
550
|
+
mime_type.extensions.each { |ext| @simplified_index[ext] ||= mime_type }
|
551
|
+
end
|
552
|
+
|
553
|
+
@__types__ = self.new(VERSION)
|
554
|
+
|
555
|
+
# Returns a list of MIME::Type objects, which may be empty. The optional
|
556
|
+
# flag parameters are :complete (finds only complete MIME::Type objects)
|
557
|
+
# and :platform (finds only MIME::Types for the current platform). It is
|
558
|
+
# possible for multiple matches to be returned for either type (in the
|
559
|
+
# example below, 'text/plain' returns two values -- one for the general
|
560
|
+
# case, and one for VMS systems.
|
561
|
+
#
|
562
|
+
# puts "\nMIME::Types['text/plain']"
|
563
|
+
# MIME::Types['text/plain'].each { |t| puts t.to_a.join(", ") }
|
564
|
+
#
|
565
|
+
# puts "\nMIME::Types[/^image/, :complete => true]"
|
566
|
+
# MIME::Types[/^image/, :complete => true].each do |t|
|
567
|
+
# puts t.to_a.join(", ")
|
568
|
+
# end
|
569
|
+
def [](type_id, flags = {})
|
570
|
+
if type_id.kind_of?(Regexp)
|
571
|
+
matches = []
|
572
|
+
@type_variants.each_key do |k|
|
573
|
+
matches << @type_variants[k] if k =~ type_id
|
574
|
+
end
|
575
|
+
matches.flatten!
|
576
|
+
elsif type_id.kind_of?(MIME::Type)
|
577
|
+
matches = [type_id]
|
578
|
+
else
|
579
|
+
matches = @type_variants[MIME::Type.simplified(type_id)]
|
580
|
+
end
|
581
|
+
|
582
|
+
matches.delete_if { |e| not e.complete? } if flags[:complete]
|
583
|
+
matches.delete_if { |e| not e.platform? } if flags[:platform]
|
584
|
+
matches
|
585
|
+
end
|
586
|
+
|
587
|
+
# Return the list of MIME::Types which belongs to the file based on its
|
588
|
+
# filename extension. If +platform+ is +true+, then only file types that
|
589
|
+
# are specific to the current platform will be returned.
|
590
|
+
#
|
591
|
+
# puts "MIME::Types.type_for('citydesk.xml')
|
592
|
+
# => "#{MIME::Types.type_for('citydesk.xml')}"
|
593
|
+
# puts "MIME::Types.type_for('citydesk.gif')
|
594
|
+
# => "#{MIME::Types.type_for('citydesk.gif')}"
|
595
|
+
def type_for(filename, platform = false)
|
596
|
+
#ext = filename.chomp.downcase.gsub(/.*\./o, '')
|
597
|
+
pos = filename.rindex(Cdot)
|
598
|
+
ext = pos ? filename[pos+1..-1] : nil
|
599
|
+
list = @extension_index[ext]
|
600
|
+
list.delete_if { |e| not e.platform? } if platform
|
601
|
+
list
|
602
|
+
end
|
603
|
+
|
604
|
+
def simple_type_for(filename)
|
605
|
+
pos = filename.rindex(Cdot)
|
606
|
+
pos ? @simplified_index[filename[pos+1..-1]] : nil
|
607
|
+
end
|
608
|
+
|
609
|
+
# A synonym for MIME::Types.type_for
|
610
|
+
def of(filename, platform = false)
|
611
|
+
type_for(filename, platform)
|
612
|
+
end
|
613
|
+
|
614
|
+
# Add one or more MIME::Type objects to the set of known types. Each
|
615
|
+
# type should be experimental (e.g., 'application/x-ruby'). If the type
|
616
|
+
# is already known, a warning will be displayed.
|
617
|
+
#
|
618
|
+
# <b>Please inform the maintainer of this module when registered types
|
619
|
+
# are missing.</b>
|
620
|
+
def add(*types)
|
621
|
+
types.each do |mime_type|
|
622
|
+
if @type_variants.include?(mime_type.simplified)
|
623
|
+
if @type_variants[mime_type.simplified].include?(mime_type)
|
624
|
+
warn "Type #{mime_type} already registered as a variant of #{mime_type.simplified}."
|
625
|
+
end
|
626
|
+
end
|
627
|
+
add_type_variant(mime_type)
|
628
|
+
index_extensions(mime_type)
|
629
|
+
simplified_extensions(mime_type)
|
630
|
+
end
|
631
|
+
end
|
632
|
+
|
633
|
+
class <<self
|
634
|
+
def add_type_variant(mime_type) #:nodoc:
|
635
|
+
@__types__.add_type_variant(mime_type)
|
636
|
+
end
|
637
|
+
|
638
|
+
def index_extensions(mime_type) #:nodoc:
|
639
|
+
@__types__.index_extensions(mime_type)
|
640
|
+
end
|
641
|
+
|
642
|
+
def simplified_extensions(mime_type) #:nodoc:
|
643
|
+
@__types__.simplified_extensions(mime_type)
|
644
|
+
end
|
645
|
+
|
646
|
+
# Returns a list of MIME::Type objects, which may be empty. The
|
647
|
+
# optional flag parameters are :complete (finds only complete
|
648
|
+
# MIME::Type objects) and :platform (finds only MIME::Types for the
|
649
|
+
# current platform). It is possible for multiple matches to be
|
650
|
+
# returned for either type (in the example below, 'text/plain' returns
|
651
|
+
# two values -- one for the general case, and one for VMS systems.
|
652
|
+
#
|
653
|
+
# puts "\nMIME::Types['text/plain']"
|
654
|
+
# MIME::Types['text/plain'].each { |t| puts t.to_a.join(", ") }
|
655
|
+
#
|
656
|
+
# puts "\nMIME::Types[/^image/, :complete => true]"
|
657
|
+
# MIME::Types[/^image/, :complete => true].each do |t|
|
658
|
+
# puts t.to_a.join(", ")
|
659
|
+
# end
|
660
|
+
def [](type_id, flags = {})
|
661
|
+
@__types__[type_id, flags]
|
662
|
+
end
|
663
|
+
|
664
|
+
# Return the list of MIME::Types which belongs to the file based on
|
665
|
+
# its filename extension. If +platform+ is +true+, then only file
|
666
|
+
# types that are specific to the current platform will be returned.
|
667
|
+
#
|
668
|
+
# puts "MIME::Types.type_for('citydesk.xml')
|
669
|
+
# => "#{MIME::Types.type_for('citydesk.xml')}"
|
670
|
+
# puts "MIME::Types.type_for('citydesk.gif')
|
671
|
+
# => "#{MIME::Types.type_for('citydesk.gif')}"
|
672
|
+
def type_for(filename, platform = false)
|
673
|
+
@__types__.type_for(filename, platform)
|
674
|
+
end
|
675
|
+
|
676
|
+
def simple_type_for(filename)
|
677
|
+
@__types__.simple_type_for(filename)
|
678
|
+
end
|
679
|
+
|
680
|
+
# A synonym for MIME::Types.type_for
|
681
|
+
def of(filename, platform = false)
|
682
|
+
@__types__.type_for(filename, platform)
|
683
|
+
end
|
684
|
+
|
685
|
+
# Add one or more MIME::Type objects to the set of known types. Each
|
686
|
+
# type should be experimental (e.g., 'application/x-ruby'). If the
|
687
|
+
# type is already known, a warning will be displayed.
|
688
|
+
#
|
689
|
+
# <b>Please inform the maintainer of this module when registered types
|
690
|
+
# are missing.</b>
|
691
|
+
def add(*types)
|
692
|
+
@__types__.add(*types)
|
693
|
+
end
|
694
|
+
end
|
695
|
+
end
|
696
|
+
end
|
697
|
+
|
698
|
+
# Build the type list
|
699
|
+
data_mime_type = <<MIME_TYPES
|
700
|
+
# What follows is the compiled list of known media types, IANA-registered
|
701
|
+
# ones first, one per line.
|
702
|
+
#
|
703
|
+
# [*][!][os:]mt/st[<ws>@ext][<ws>:enc][<ws>'url-list][<ws>=docs]
|
704
|
+
#
|
705
|
+
# == *
|
706
|
+
# An unofficial MIME type. This should be used if an only if the MIME type
|
707
|
+
# is not properly specified.
|
708
|
+
#
|
709
|
+
# == !
|
710
|
+
# An obsolete MIME type.
|
711
|
+
#
|
712
|
+
# == os:
|
713
|
+
# Platform-specific MIME type definition.
|
714
|
+
#
|
715
|
+
# == mt
|
716
|
+
# The media type.
|
717
|
+
#
|
718
|
+
# == st
|
719
|
+
# The media subtype.
|
720
|
+
#
|
721
|
+
# == <ws>@ext
|
722
|
+
# The list of comma-separated extensions.
|
723
|
+
#
|
724
|
+
# == <ws>:enc
|
725
|
+
# The encoding.
|
726
|
+
#
|
727
|
+
# == <ws>'url-list
|
728
|
+
# The list of comma-separated URLs.
|
729
|
+
#
|
730
|
+
# == <ws>=docs
|
731
|
+
# The documentation string.
|
732
|
+
#
|
733
|
+
# That is, everything except the media type and the subtype is optional.
|
734
|
+
#
|
735
|
+
# -- Austin Ziegler, 2006.02.12
|
736
|
+
|
737
|
+
# Registered: application/*
|
738
|
+
!application/xhtml-voice+xml 'DRAFT:draft-mccobb-xplusv-media-type
|
739
|
+
application/CSTAdata+xml 'IANA,[Ecma International Helpdesk]
|
740
|
+
application/EDI-Consent 'RFC1767
|
741
|
+
application/EDI-X12 'RFC1767
|
742
|
+
application/EDIFACT 'RFC1767
|
743
|
+
application/activemessage 'IANA,[Shapiro]
|
744
|
+
application/andrew-inset 'IANA,[Borenstein]
|
745
|
+
application/applefile :base64 'IANA,[Faltstrom]
|
746
|
+
application/atom+xml 'RFC4287
|
747
|
+
application/atomicmail 'IANA,[Borenstein]
|
748
|
+
application/batch-SMTP 'RFC2442
|
749
|
+
application/beep+xml 'RFC3080
|
750
|
+
application/cals-1840 'RFC1895
|
751
|
+
application/ccxml+xml 'DRAFT:draft-froumentin-voice-mediatypes
|
752
|
+
application/cnrp+xml 'RFCCNRP
|
753
|
+
application/commonground 'IANA,[Glazer]
|
754
|
+
application/conference-info+xml 'DRAFT:draft-ietf-sipping-conference-package
|
755
|
+
application/cpl+xml 'RFC3880
|
756
|
+
application/csta+xml 'IANA,[Ecma International Helpdesk]
|
757
|
+
application/cybercash 'IANA,[Eastlake]
|
758
|
+
application/dca-rft 'IANA,[Campbell]
|
759
|
+
application/dec-dx 'IANA,[Campbell]
|
760
|
+
application/dialog-info+xml 'DRAFT:draft-ietf-sipping-dialog-package
|
761
|
+
application/dicom 'RFC3240
|
762
|
+
application/dns 'RFC4027
|
763
|
+
application/dvcs 'RFC3029
|
764
|
+
application/ecmascript 'DRAFT:draft-hoehrmann-script-types
|
765
|
+
application/epp+xml 'RFC3730
|
766
|
+
application/eshop 'IANA,[Katz]
|
767
|
+
application/fastinfoset 'IANA,[ITU-T ASN.1 Rapporteur]
|
768
|
+
application/fastsoap 'IANA,[ITU-T ASN.1 Rapporteur]
|
769
|
+
application/fits 'RFC4047
|
770
|
+
application/font-tdpfr @pfr 'RFC3073
|
771
|
+
application/http 'RFC2616
|
772
|
+
application/hyperstudio @stk 'IANA,[Domino]
|
773
|
+
application/iges 'IANA,[Parks]
|
774
|
+
application/im-iscomposing+xml 'RFC3994
|
775
|
+
application/index 'RFC2652
|
776
|
+
application/index.cmd 'RFC2652
|
777
|
+
application/index.obj 'RFC2652
|
778
|
+
application/index.response 'RFC2652
|
779
|
+
application/index.vnd 'RFC2652
|
780
|
+
application/iotp 'RFC2935
|
781
|
+
application/ipp 'RFC2910
|
782
|
+
application/isup 'RFC3204
|
783
|
+
application/javascript @js :8bit 'DRAFT:draft-hoehrmann-script-types
|
784
|
+
application/kpml-request+xml 'DRAFT:draft-ietf-sipping-kpml
|
785
|
+
application/kpml-response+xml 'DRAFT:draft-ietf-sipping-kpml
|
786
|
+
application/mac-binhex40 @hqx :8bit 'IANA,[Faltstrom]
|
787
|
+
application/macwriteii 'IANA,[Lindner]
|
788
|
+
application/marc 'RFC2220
|
789
|
+
application/mathematica 'IANA,[Van Nostern]
|
790
|
+
application/mbox 'DRAFT:draft-hall-mime-app-mbox
|
791
|
+
application/mikey 'RFC3830
|
792
|
+
application/mp4 'DRAFT:draft-lim-mpeg4-mime
|
793
|
+
application/mpeg4-generic 'RFC3640
|
794
|
+
application/mpeg4-iod 'DRAFT:draft-lim-mpeg4-mime
|
795
|
+
application/mpeg4-iod-xmt 'DRAFT:draft-lim-mpeg4-mime
|
796
|
+
application/msword @doc,dot :base64 'IANA,[Lindner]
|
797
|
+
application/news-message-id 'RFC1036,[Spencer]
|
798
|
+
application/news-transmission 'RFC1036,[Spencer]
|
799
|
+
application/nss 'IANA,[Hammer]
|
800
|
+
application/ocsp-request 'RFC2560
|
801
|
+
application/ocsp-response 'RFC2560
|
802
|
+
application/octet-stream @bin,dms,lha,lzh,exe,class,ani,pgp :base64 'RFC2045,RFC2046
|
803
|
+
application/oda @oda 'RFC2045,RFC2046
|
804
|
+
application/ogg @ogg 'RFC3534
|
805
|
+
application/parityfec 'RFC3009
|
806
|
+
application/pdf @pdf :base64 'RFC3778
|
807
|
+
application/pgp-encrypted :7bit 'RFC3156
|
808
|
+
application/pgp-keys :7bit 'RFC3156
|
809
|
+
application/pgp-signature @sig :base64 'RFC3156
|
810
|
+
application/pidf+xml 'IANA,RFC3863
|
811
|
+
application/pkcs10 @p10 'RFC2311
|
812
|
+
application/pkcs7-mime @p7m,p7c 'RFC2311
|
813
|
+
application/pkcs7-signature @p7s 'RFC2311
|
814
|
+
application/pkix-cert @cer 'RFC2585
|
815
|
+
application/pkix-crl @crl 'RFC2585
|
816
|
+
application/pkix-pkipath @pkipath 'DRAFT:draft-ietf-tls-rfc3546bis
|
817
|
+
application/pkixcmp @pki 'RFC2510
|
818
|
+
application/pls+xml 'DRAFT:draft-froumentin-voice-mediatypes
|
819
|
+
application/poc-settings+xml 'DRAFT:draft-garcia-sipping-poc-isb-am
|
820
|
+
application/postscript @ai,eps,ps :8bit 'RFC2045,RFC2046
|
821
|
+
application/prs.alvestrand.titrax-sheet 'IANA,[Alvestrand]
|
822
|
+
application/prs.cww @cw,cww 'IANA,[Rungchavalnont]
|
823
|
+
application/prs.nprend @rnd,rct 'IANA,[Doggett]
|
824
|
+
application/prs.plucker 'IANA,[Janssen]
|
825
|
+
application/qsig 'RFC3204
|
826
|
+
application/rdf+xml @rdf 'RFC3870
|
827
|
+
application/reginfo+xml 'RFC3680
|
828
|
+
application/remote-printing 'IANA,RFC1486,[Rose]
|
829
|
+
application/resource-lists+xml 'DRAFT:draft-ietf-simple-xcap-list-usage
|
830
|
+
application/riscos 'IANA,[Smith]
|
831
|
+
application/rlmi+xml 'DRAFT:draft-ietf-simple-event-list
|
832
|
+
application/rls-services+xml 'DRAFT:draft-ietf-simple-xcap-list-usage
|
833
|
+
application/rtf @rtf 'IANA,[Lindner]
|
834
|
+
application/rtx 'DRAFT:draft-ietf-avt-rtp-retransmission
|
835
|
+
application/samlassertion+xml 'IANA,[OASIS Security Services Technical Committee (SSTC)]
|
836
|
+
application/samlmetadata+xml 'IANA,[OASIS Security Services Technical Committee (SSTC)]
|
837
|
+
application/sbml+xml 'RFC3823
|
838
|
+
application/sdp 'RFC2327
|
839
|
+
application/set-payment 'IANA,[Korver]
|
840
|
+
application/set-payment-initiation 'IANA,[Korver]
|
841
|
+
application/set-registration 'IANA,[Korver]
|
842
|
+
application/set-registration-initiation 'IANA,[Korver]
|
843
|
+
application/sgml @sgml 'RFC1874
|
844
|
+
application/sgml-open-catalog @soc 'IANA,[Grosso]
|
845
|
+
application/shf+xml 'RFC4194
|
846
|
+
application/sieve @siv 'RFC3028
|
847
|
+
application/simple-filter+xml 'DRAFT:draft-ietf-simple-filter-format
|
848
|
+
application/simple-message-summary 'RFC3842
|
849
|
+
application/slate 'IANA,[Crowley]
|
850
|
+
application/soap+fastinfoset 'IANA,[ITU-T ASN.1 Rapporteur]
|
851
|
+
application/soap+xml 'RFC3902
|
852
|
+
application/spirits-event+xml 'RFC3910
|
853
|
+
application/srgs 'DRAFT:draft-froumentin-voice-mediatypes
|
854
|
+
application/srgs+xml 'DRAFT:draft-froumentin-voice-mediatypes
|
855
|
+
application/ssml+xml 'DRAFT:draft-froumentin-voice-mediatypes
|
856
|
+
application/timestamp-query 'RFC3161
|
857
|
+
application/timestamp-reply 'RFC3161
|
858
|
+
application/tve-trigger 'IANA,[Welsh]
|
859
|
+
application/vemmi 'RFC2122
|
860
|
+
application/vnd.3M.Post-it-Notes 'IANA,[O'Brien]
|
861
|
+
application/vnd.3gpp.pic-bw-large @plb 'IANA,[Meredith]
|
862
|
+
application/vnd.3gpp.pic-bw-small @psb 'IANA,[Meredith]
|
863
|
+
application/vnd.3gpp.pic-bw-var @pvb 'IANA,[Meredith]
|
864
|
+
application/vnd.3gpp.sms @sms 'IANA,[Meredith]
|
865
|
+
application/vnd.FloGraphIt 'IANA,[Floersch]
|
866
|
+
application/vnd.Kinar @kne,knp,sdf 'IANA,[Thakkar]
|
867
|
+
application/vnd.Mobius.DAF 'IANA,[Kabayama]
|
868
|
+
application/vnd.Mobius.DIS 'IANA,[Kabayama]
|
869
|
+
application/vnd.Mobius.MBK 'IANA,[Devasia]
|
870
|
+
application/vnd.Mobius.MQY 'IANA,[Devasia]
|
871
|
+
application/vnd.Mobius.MSL 'IANA,[Kabayama]
|
872
|
+
application/vnd.Mobius.PLC 'IANA,[Kabayama]
|
873
|
+
application/vnd.Mobius.TXF 'IANA,[Kabayama]
|
874
|
+
application/vnd.Quark.QuarkXPress @qxd,qxt,qwd,qwt,qxl,qxb :8bit 'IANA,[Scheidler]
|
875
|
+
application/vnd.RenLearn.rlprint 'IANA,[Wick]
|
876
|
+
application/vnd.accpac.simply.aso 'IANA,[Leow]
|
877
|
+
application/vnd.accpac.simply.imp 'IANA,[Leow]
|
878
|
+
application/vnd.acucobol 'IANA,[Lubin]
|
879
|
+
application/vnd.acucorp @atc,acutc :7bit 'IANA,[Lubin]
|
880
|
+
application/vnd.adobe.xfdf @xfdf 'IANA,[Perelman]
|
881
|
+
application/vnd.aether.imp 'IANA,[Moskowitz]
|
882
|
+
application/vnd.amiga.ami @ami 'IANA,[Blumberg]
|
883
|
+
application/vnd.apple.installer+xml 'IANA,[Bierman]
|
884
|
+
application/vnd.audiograph 'IANA,[Slusanschi]
|
885
|
+
application/vnd.autopackage 'IANA,[Hearn]
|
886
|
+
application/vnd.blueice.multipass @mpm 'IANA,[Holmstrom]
|
887
|
+
application/vnd.bmi 'IANA,[Gotoh]
|
888
|
+
application/vnd.businessobjects 'IANA,[Imoucha]
|
889
|
+
application/vnd.cinderella @cdy 'IANA,[Kortenkamp]
|
890
|
+
application/vnd.claymore 'IANA,[Simpson]
|
891
|
+
application/vnd.commerce-battelle 'IANA,[Applebaum]
|
892
|
+
application/vnd.commonspace 'IANA,[Chandhok]
|
893
|
+
application/vnd.contact.cmsg 'IANA,[Patz]
|
894
|
+
application/vnd.cosmocaller @cmc 'IANA,[Dellutri]
|
895
|
+
application/vnd.criticaltools.wbs+xml @wbs 'IANA,[Spiller]
|
896
|
+
application/vnd.ctc-posml 'IANA,[Kohlhepp]
|
897
|
+
application/vnd.cups-postscript 'IANA,[Sweet]
|
898
|
+
application/vnd.cups-raster 'IANA,[Sweet]
|
899
|
+
application/vnd.cups-raw 'IANA,[Sweet]
|
900
|
+
application/vnd.curl @curl 'IANA,[Byrnes]
|
901
|
+
application/vnd.cybank 'IANA,[Helmee]
|
902
|
+
application/vnd.data-vision.rdz @rdz 'IANA,[Fields]
|
903
|
+
application/vnd.dna 'IANA,[Searcy]
|
904
|
+
application/vnd.dpgraph 'IANA,[Parker]
|
905
|
+
application/vnd.dreamfactory @dfac 'IANA,[Appleton]
|
906
|
+
application/vnd.dxr 'IANA,[Duffy]
|
907
|
+
application/vnd.ecdis-update 'IANA,[Buettgenbach]
|
908
|
+
application/vnd.ecowin.chart 'IANA,[Olsson]
|
909
|
+
application/vnd.ecowin.filerequest 'IANA,[Olsson]
|
910
|
+
application/vnd.ecowin.fileupdate 'IANA,[Olsson]
|
911
|
+
application/vnd.ecowin.series 'IANA,[Olsson]
|
912
|
+
application/vnd.ecowin.seriesrequest 'IANA,[Olsson]
|
913
|
+
application/vnd.ecowin.seriesupdate 'IANA,[Olsson]
|
914
|
+
application/vnd.enliven 'IANA,[Santinelli]
|
915
|
+
application/vnd.epson.esf 'IANA,[Hoshina]
|
916
|
+
application/vnd.epson.msf 'IANA,[Hoshina]
|
917
|
+
application/vnd.epson.quickanime 'IANA,[Gu]
|
918
|
+
application/vnd.epson.salt 'IANA,[Nagatomo]
|
919
|
+
application/vnd.epson.ssf 'IANA,[Hoshina]
|
920
|
+
application/vnd.ericsson.quickcall 'IANA,[Tidwell]
|
921
|
+
application/vnd.eudora.data 'IANA,[Resnick]
|
922
|
+
application/vnd.fdf 'IANA,[Zilles]
|
923
|
+
application/vnd.ffsns 'IANA,[Holstage]
|
924
|
+
application/vnd.fints 'IANA,[Hammann]
|
925
|
+
application/vnd.fluxtime.clip 'IANA,[Winter]
|
926
|
+
application/vnd.framemaker 'IANA,[Wexler]
|
927
|
+
application/vnd.fsc.weblaunch @fsc :7bit 'IANA,[D.Smith]
|
928
|
+
application/vnd.fujitsu.oasys 'IANA,[Togashi]
|
929
|
+
application/vnd.fujitsu.oasys2 'IANA,[Togashi]
|
930
|
+
application/vnd.fujitsu.oasys3 'IANA,[Okudaira]
|
931
|
+
application/vnd.fujitsu.oasysgp 'IANA,[Sugimoto]
|
932
|
+
application/vnd.fujitsu.oasysprs 'IANA,[Ogita]
|
933
|
+
application/vnd.fujixerox.ddd 'IANA,[Onda]
|
934
|
+
application/vnd.fujixerox.docuworks 'IANA,[Taguchi]
|
935
|
+
application/vnd.fujixerox.docuworks.binder 'IANA,[Matsumoto]
|
936
|
+
application/vnd.fut-misnet 'IANA,[Pruulmann]
|
937
|
+
application/vnd.genomatix.tuxedo @txd 'IANA,[Frey]
|
938
|
+
application/vnd.grafeq 'IANA,[Tupper]
|
939
|
+
application/vnd.groove-account 'IANA,[Joseph]
|
940
|
+
application/vnd.groove-help 'IANA,[Joseph]
|
941
|
+
application/vnd.groove-identity-message 'IANA,[Joseph]
|
942
|
+
application/vnd.groove-injector 'IANA,[Joseph]
|
943
|
+
application/vnd.groove-tool-message 'IANA,[Joseph]
|
944
|
+
application/vnd.groove-tool-template 'IANA,[Joseph]
|
945
|
+
application/vnd.groove-vcard 'IANA,[Joseph]
|
946
|
+
application/vnd.hbci @hbci,hbc,kom,upa,pkd,bpd 'IANA,[Hammann]
|
947
|
+
application/vnd.hcl-bireports 'IANA,[Serres]
|
948
|
+
application/vnd.hhe.lesson-player @les 'IANA,[Jones]
|
949
|
+
application/vnd.hp-HPGL @plt,hpgl 'IANA,[Pentecost]
|
950
|
+
application/vnd.hp-PCL 'IANA,[Pentecost]
|
951
|
+
application/vnd.hp-PCLXL 'IANA,[Pentecost]
|
952
|
+
application/vnd.hp-hpid 'IANA,[Gupta]
|
953
|
+
application/vnd.hp-hps 'IANA,[Aubrey]
|
954
|
+
application/vnd.httphone 'IANA,[Lefevre]
|
955
|
+
application/vnd.hzn-3d-crossword 'IANA,[Minnis]
|
956
|
+
application/vnd.ibm.MiniPay 'IANA,[Herzberg]
|
957
|
+
application/vnd.ibm.afplinedata 'IANA,[Buis]
|
958
|
+
application/vnd.ibm.electronic-media @emm 'IANA,[Tantlinger]
|
959
|
+
application/vnd.ibm.modcap 'IANA,[Hohensee]
|
960
|
+
application/vnd.ibm.rights-management @irm 'IANA,[Tantlinger]
|
961
|
+
application/vnd.ibm.secure-container @sc 'IANA,[Tantlinger]
|
962
|
+
application/vnd.informix-visionary 'IANA,[Gales]
|
963
|
+
application/vnd.intercon.formnet 'IANA,[Gurak]
|
964
|
+
application/vnd.intertrust.digibox 'IANA,[Tomasello]
|
965
|
+
application/vnd.intertrust.nncp 'IANA,[Tomasello]
|
966
|
+
application/vnd.intu.qbo 'IANA,[Scratchley]
|
967
|
+
application/vnd.intu.qfx 'IANA,[Scratchley]
|
968
|
+
application/vnd.ipunplugged.rcprofile @rcprofile 'IANA,[Ersson]
|
969
|
+
application/vnd.irepository.package+xml @irp 'IANA,[Knowles]
|
970
|
+
application/vnd.is-xpr 'IANA,[Natarajan]
|
971
|
+
application/vnd.japannet-directory-service 'IANA,[Fujii]
|
972
|
+
application/vnd.japannet-jpnstore-wakeup 'IANA,[Yoshitake]
|
973
|
+
application/vnd.japannet-payment-wakeup 'IANA,[Fujii]
|
974
|
+
application/vnd.japannet-registration 'IANA,[Yoshitake]
|
975
|
+
application/vnd.japannet-registration-wakeup 'IANA,[Fujii]
|
976
|
+
application/vnd.japannet-setstore-wakeup 'IANA,[Yoshitake]
|
977
|
+
application/vnd.japannet-verification 'IANA,[Yoshitake]
|
978
|
+
application/vnd.japannet-verification-wakeup 'IANA,[Fujii]
|
979
|
+
application/vnd.jisp @jisp 'IANA,[Deckers]
|
980
|
+
application/vnd.kahootz 'IANA,[Macdonald]
|
981
|
+
application/vnd.kde.karbon @karbon 'IANA,[Faure]
|
982
|
+
application/vnd.kde.kchart @chrt 'IANA,[Faure]
|
983
|
+
application/vnd.kde.kformula @kfo 'IANA,[Faure]
|
984
|
+
application/vnd.kde.kivio @flw 'IANA,[Faure]
|
985
|
+
application/vnd.kde.kontour @kon 'IANA,[Faure]
|
986
|
+
application/vnd.kde.kpresenter @kpr,kpt 'IANA,[Faure]
|
987
|
+
application/vnd.kde.kspread @ksp 'IANA,[Faure]
|
988
|
+
application/vnd.kde.kword @kwd,kwt 'IANA,[Faure]
|
989
|
+
application/vnd.kenameaapp @htke 'IANA,[DiGiorgio-Haag]
|
990
|
+
application/vnd.kidspiration @kia 'IANA,[Bennett]
|
991
|
+
application/vnd.koan 'IANA,[Cole]
|
992
|
+
application/vnd.liberty-request+xml 'IANA,[McDowell]
|
993
|
+
application/vnd.llamagraphics.life-balance.desktop @lbd 'IANA,[White]
|
994
|
+
application/vnd.llamagraphics.life-balance.exchange+xml @lbe 'IANA,[White]
|
995
|
+
application/vnd.lotus-1-2-3 @wks,123 'IANA,[Wattenberger]
|
996
|
+
application/vnd.lotus-approach 'IANA,[Wattenberger]
|
997
|
+
application/vnd.lotus-freelance 'IANA,[Wattenberger]
|
998
|
+
application/vnd.lotus-notes 'IANA,[Laramie]
|
999
|
+
application/vnd.lotus-organizer 'IANA,[Wattenberger]
|
1000
|
+
application/vnd.lotus-screencam 'IANA,[Wattenberger]
|
1001
|
+
application/vnd.lotus-wordpro 'IANA,[Wattenberger]
|
1002
|
+
application/vnd.marlin.drm.mdcf 'IANA,[Ellison]
|
1003
|
+
application/vnd.mcd @mcd 'IANA,[Gotoh]
|
1004
|
+
application/vnd.mediastation.cdkey 'IANA,[Flurry]
|
1005
|
+
application/vnd.meridian-slingshot 'IANA,[Wedel]
|
1006
|
+
application/vnd.mfmp @mfm 'IANA,[Ikeda]
|
1007
|
+
application/vnd.micrografx.flo @flo 'IANA,[Prevo]
|
1008
|
+
application/vnd.micrografx.igx @igx 'IANA,[Prevo]
|
1009
|
+
application/vnd.mif @mif 'IANA,[Wexler]
|
1010
|
+
application/vnd.minisoft-hp3000-save 'IANA,[Bartram]
|
1011
|
+
application/vnd.mitsubishi.misty-guard.trustweb 'IANA,[Tanaka]
|
1012
|
+
application/vnd.mophun.application @mpn 'IANA,[Wennerstrom]
|
1013
|
+
application/vnd.mophun.certificate @mpc 'IANA,[Wennerstrom]
|
1014
|
+
application/vnd.motorola.flexsuite 'IANA,[Patton]
|
1015
|
+
application/vnd.motorola.flexsuite.adsi 'IANA,[Patton]
|
1016
|
+
application/vnd.motorola.flexsuite.fis 'IANA,[Patton]
|
1017
|
+
application/vnd.motorola.flexsuite.gotap 'IANA,[Patton]
|
1018
|
+
application/vnd.motorola.flexsuite.kmr 'IANA,[Patton]
|
1019
|
+
application/vnd.motorola.flexsuite.ttc 'IANA,[Patton]
|
1020
|
+
application/vnd.motorola.flexsuite.wem 'IANA,[Patton]
|
1021
|
+
application/vnd.mozilla.xul+xml @xul 'IANA,[McDaniel]
|
1022
|
+
application/vnd.ms-artgalry @cil 'IANA,[Slawson]
|
1023
|
+
application/vnd.ms-asf @asf 'IANA,[Fleischman]
|
1024
|
+
application/vnd.ms-cab-compressed @cab 'IANA,[Scarborough]
|
1025
|
+
application/vnd.ms-excel @xls,xlt :base64 'IANA,[Gill]
|
1026
|
+
application/vnd.ms-fontobject 'IANA,[Scarborough]
|
1027
|
+
application/vnd.ms-ims 'IANA,[Ledoux]
|
1028
|
+
application/vnd.ms-lrm @lrm 'IANA,[Ledoux]
|
1029
|
+
application/vnd.ms-powerpoint @ppt,pps,pot :base64 'IANA,[Gill]
|
1030
|
+
application/vnd.ms-project @mpp :base64 'IANA,[Gill]
|
1031
|
+
application/vnd.ms-tnef :base64 'IANA,[Gill]
|
1032
|
+
application/vnd.ms-works :base64 'IANA,[Gill]
|
1033
|
+
application/vnd.ms-wpl @wpl :base64 'IANA,[Plastina]
|
1034
|
+
application/vnd.mseq @mseq 'IANA,[Le Bodic]
|
1035
|
+
application/vnd.msign 'IANA,[Borcherding]
|
1036
|
+
application/vnd.music-niff 'IANA,[Butler]
|
1037
|
+
application/vnd.musician 'IANA,[Adams]
|
1038
|
+
application/vnd.nervana @ent,entity,req,request,bkm,kcm 'IANA,[Judkins]
|
1039
|
+
application/vnd.netfpx 'IANA,[Mutz]
|
1040
|
+
application/vnd.noblenet-directory 'IANA,[Solomon]
|
1041
|
+
application/vnd.noblenet-sealer 'IANA,[Solomon]
|
1042
|
+
application/vnd.noblenet-web 'IANA,[Solomon]
|
1043
|
+
application/vnd.nokia.landmark+wbxml 'IANA,[Nokia]
|
1044
|
+
application/vnd.nokia.landmark+xml 'IANA,[Nokia]
|
1045
|
+
application/vnd.nokia.landmarkcollection+xml 'IANA,[Nokia]
|
1046
|
+
application/vnd.nokia.radio-preset @rpst 'IANA,[Nokia]
|
1047
|
+
application/vnd.nokia.radio-presets @rpss 'IANA,[Nokia]
|
1048
|
+
application/vnd.novadigm.EDM 'IANA,[Swenson]
|
1049
|
+
application/vnd.novadigm.EDX 'IANA,[Swenson]
|
1050
|
+
application/vnd.novadigm.EXT 'IANA,[Swenson]
|
1051
|
+
application/vnd.obn 'IANA,[Hessling]
|
1052
|
+
application/vnd.omads-email+xml 'IANA,[OMA Data Synchronization Working Group]
|
1053
|
+
application/vnd.omads-file+xml 'IANA,[OMA Data Synchronization Working Group]
|
1054
|
+
application/vnd.omads-folder+xml 'IANA,[OMA Data Synchronization Working Group]
|
1055
|
+
application/vnd.osa.netdeploy 'IANA,[Klos]
|
1056
|
+
application/vnd.osgi.dp 'IANA,[Kriens]
|
1057
|
+
application/vnd.palm @prc,pdb,pqa,oprc :base64 'IANA,[Peacock]
|
1058
|
+
application/vnd.paos.xml 'IANA,[Kemp]
|
1059
|
+
application/vnd.pg.format 'IANA,[Gandert]
|
1060
|
+
application/vnd.pg.osasli 'IANA,[Gandert]
|
1061
|
+
application/vnd.piaccess.application-licence 'IANA,[Maneos]
|
1062
|
+
application/vnd.picsel @efif 'IANA,[Naccarato]
|
1063
|
+
application/vnd.powerbuilder6 'IANA,[Guy]
|
1064
|
+
application/vnd.powerbuilder6-s 'IANA,[Guy]
|
1065
|
+
application/vnd.powerbuilder7 'IANA,[Shilts]
|
1066
|
+
application/vnd.powerbuilder7-s 'IANA,[Shilts]
|
1067
|
+
application/vnd.powerbuilder75 'IANA,[Shilts]
|
1068
|
+
application/vnd.powerbuilder75-s 'IANA,[Shilts]
|
1069
|
+
application/vnd.preminet 'IANA,[Tenhunen]
|
1070
|
+
application/vnd.previewsystems.box 'IANA,[Smolgovsky]
|
1071
|
+
application/vnd.proteus.magazine 'IANA,[Hoch]
|
1072
|
+
application/vnd.publishare-delta-tree 'IANA,[Ben-Kiki]
|
1073
|
+
application/vnd.pvi.ptid1 @pti,ptid 'IANA,[Lamb]
|
1074
|
+
application/vnd.pwg-multiplexed 'RFC3391
|
1075
|
+
application/vnd.pwg-xhtml-print+xml 'IANA,[Wright]
|
1076
|
+
application/vnd.rapid 'IANA,[Szekely]
|
1077
|
+
application/vnd.ruckus.download 'IANA,[Harris]
|
1078
|
+
application/vnd.s3sms 'IANA,[Tarkkala]
|
1079
|
+
application/vnd.sealed.doc @sdoc,sdo,s1w 'IANA,[Petersen]
|
1080
|
+
application/vnd.sealed.eml @seml,sem 'IANA,[Petersen]
|
1081
|
+
application/vnd.sealed.mht @smht,smh 'IANA,[Petersen]
|
1082
|
+
application/vnd.sealed.net 'IANA,[Lambert]
|
1083
|
+
application/vnd.sealed.ppt @sppt,spp,s1p 'IANA,[Petersen]
|
1084
|
+
application/vnd.sealed.xls @sxls,sxl,s1e 'IANA,[Petersen]
|
1085
|
+
application/vnd.sealedmedia.softseal.html @stml,stm,s1h 'IANA,[Petersen]
|
1086
|
+
application/vnd.sealedmedia.softseal.pdf @spdf,spd,s1a 'IANA,[Petersen]
|
1087
|
+
application/vnd.seemail @see 'IANA,[Webb]
|
1088
|
+
application/vnd.sema 'IANA,[Hansson]
|
1089
|
+
application/vnd.shana.informed.formdata 'IANA,[Selzler]
|
1090
|
+
application/vnd.shana.informed.formtemplate 'IANA,[Selzler]
|
1091
|
+
application/vnd.shana.informed.interchange 'IANA,[Selzler]
|
1092
|
+
application/vnd.shana.informed.package 'IANA,[Selzler]
|
1093
|
+
application/vnd.smaf @mmf 'IANA,[Takahashi]
|
1094
|
+
application/vnd.sss-cod 'IANA,[Dani]
|
1095
|
+
application/vnd.sss-dtf 'IANA,[Bruno]
|
1096
|
+
application/vnd.sss-ntf 'IANA,[Bruno]
|
1097
|
+
application/vnd.street-stream 'IANA,[Levitt]
|
1098
|
+
application/vnd.sus-calendar @sus,susp 'IANA,[Niedfeldt]
|
1099
|
+
application/vnd.svd 'IANA,[Becker]
|
1100
|
+
application/vnd.swiftview-ics 'IANA,[Widener]
|
1101
|
+
application/vnd.syncml.+xml 'IANA,[OMA Data Synchronization Working Group]
|
1102
|
+
application/vnd.syncml.ds.notification 'IANA,[OMA Data Synchronization Working Group]
|
1103
|
+
application/vnd.triscape.mxs 'IANA,[Simonoff]
|
1104
|
+
application/vnd.trueapp 'IANA,[Hepler]
|
1105
|
+
application/vnd.truedoc 'IANA,[Chase]
|
1106
|
+
application/vnd.ufdl 'IANA,[Manning]
|
1107
|
+
application/vnd.uiq.theme 'IANA,[Ocock]
|
1108
|
+
application/vnd.uplanet.alert 'IANA,[Martin]
|
1109
|
+
application/vnd.uplanet.alert-wbxml 'IANA,[Martin]
|
1110
|
+
application/vnd.uplanet.bearer-choice 'IANA,[Martin]
|
1111
|
+
application/vnd.uplanet.bearer-choice-wbxml 'IANA,[Martin]
|
1112
|
+
application/vnd.uplanet.cacheop 'IANA,[Martin]
|
1113
|
+
application/vnd.uplanet.cacheop-wbxml 'IANA,[Martin]
|
1114
|
+
application/vnd.uplanet.channel 'IANA,[Martin]
|
1115
|
+
application/vnd.uplanet.channel-wbxml 'IANA,[Martin]
|
1116
|
+
application/vnd.uplanet.list 'IANA,[Martin]
|
1117
|
+
application/vnd.uplanet.list-wbxml 'IANA,[Martin]
|
1118
|
+
application/vnd.uplanet.listcmd 'IANA,[Martin]
|
1119
|
+
application/vnd.uplanet.listcmd-wbxml 'IANA,[Martin]
|
1120
|
+
application/vnd.uplanet.signal 'IANA,[Martin]
|
1121
|
+
application/vnd.vcx 'IANA,[T.Sugimoto]
|
1122
|
+
application/vnd.vectorworks 'IANA,[Pharr]
|
1123
|
+
application/vnd.vidsoft.vidconference @vsc :8bit 'IANA,[Hess]
|
1124
|
+
application/vnd.visio @vsd,vst,vsw,vss 'IANA,[Sandal]
|
1125
|
+
application/vnd.visionary @vis 'IANA,[Aravindakumar]
|
1126
|
+
application/vnd.vividence.scriptfile 'IANA,[Risher]
|
1127
|
+
application/vnd.vsf 'IANA,[Rowe]
|
1128
|
+
application/vnd.wap.sic @sic 'IANA,[WAP-Forum]
|
1129
|
+
application/vnd.wap.slc @slc 'IANA,[WAP-Forum]
|
1130
|
+
application/vnd.wap.wbxml @wbxml 'IANA,[Stark]
|
1131
|
+
application/vnd.wap.wmlc @wmlc 'IANA,[Stark]
|
1132
|
+
application/vnd.wap.wmlscriptc @wmlsc 'IANA,[Stark]
|
1133
|
+
application/vnd.webturbo @wtb 'IANA,[Rehem]
|
1134
|
+
application/vnd.wordperfect @wpd 'IANA,[Scarborough]
|
1135
|
+
application/vnd.wqd @wqd 'IANA,[Bostrom]
|
1136
|
+
application/vnd.wrq-hp3000-labelled 'IANA,[Bartram]
|
1137
|
+
application/vnd.wt.stf 'IANA,[Wohler]
|
1138
|
+
application/vnd.wv.csp+wbxml @wv 'IANA,[Salmi]
|
1139
|
+
application/vnd.wv.csp+xml :8bit 'IANA,[Ingimundarson]
|
1140
|
+
application/vnd.wv.ssp+xml :8bit 'IANA,[Ingimundarson]
|
1141
|
+
application/vnd.xara 'IANA,[Matthewman]
|
1142
|
+
application/vnd.xfdl 'IANA,[Manning]
|
1143
|
+
application/vnd.yamaha.hv-dic @hvd 'IANA,[Yamamoto]
|
1144
|
+
application/vnd.yamaha.hv-script @hvs 'IANA,[Yamamoto]
|
1145
|
+
application/vnd.yamaha.hv-voice @hvp 'IANA,[Yamamoto]
|
1146
|
+
application/vnd.yamaha.smaf-audio @saf 'IANA,[Shinoda]
|
1147
|
+
application/vnd.yamaha.smaf-phrase @spf 'IANA,[Shinoda]
|
1148
|
+
application/vnd.yellowriver-custom-menu 'IANA,[Yellow]
|
1149
|
+
application/vnd.zzazz.deck+xml 'IANA,[Hewett]
|
1150
|
+
application/voicexml+xml 'DRAFT:draft-froumentin-voice-mediatypes
|
1151
|
+
application/watcherinfo+xml @wif 'RFC3858
|
1152
|
+
application/whoispp-query 'RFC2957
|
1153
|
+
application/whoispp-response 'RFC2958
|
1154
|
+
application/wita 'IANA,[Campbell]
|
1155
|
+
application/wordperfect5.1 @wp5,wp 'IANA,[Lindner]
|
1156
|
+
application/x400-bp 'RFC1494
|
1157
|
+
application/xcap-att+xml 'DRAFT:draft-ietf-simple-xcap
|
1158
|
+
application/xcap-caps+xml 'DRAFT:draft-ietf-simple-xcap
|
1159
|
+
application/xcap-el+xml 'DRAFT:draft-ietf-simple-xcap
|
1160
|
+
application/xcap-error+xml 'DRAFT:draft-ietf-simple-xcap
|
1161
|
+
application/xhtml+xml @xhtml :8bit 'RFC3236
|
1162
|
+
application/xml @xml :8bit 'RFC3023
|
1163
|
+
application/xml-dtd :8bit 'RFC3023
|
1164
|
+
application/xml-external-parsed-entity 'RFC3023
|
1165
|
+
application/xmpp+xml 'RFC3923
|
1166
|
+
application/xop+xml 'IANA,[Nottingham]
|
1167
|
+
application/xv+xml 'DRAFT:draft-mccobb-xv-media-type
|
1168
|
+
application/zip @zip :base64 'IANA,[Lindner]
|
1169
|
+
|
1170
|
+
# Registered: audio/*
|
1171
|
+
!audio/vnd.qcelp 'IANA,RFC3625 =use-instead:audio/QCELP
|
1172
|
+
audio/32kadpcm 'RFC2421,RFC2422
|
1173
|
+
audio/3gpp @3gpp 'RFC3839,DRAFT:draft-gellens-bucket
|
1174
|
+
audio/3gpp2 'DRAFT:draft-garudadri-avt-3gpp2-mime
|
1175
|
+
audio/AMR @amr :base64 'RFC3267
|
1176
|
+
audio/AMR-WB @awb :base64 'RFC3267
|
1177
|
+
audio/BV16 'RFC4298
|
1178
|
+
audio/BV32 'RFC4298
|
1179
|
+
audio/CN 'RFC3389
|
1180
|
+
audio/DAT12 'RFC3190
|
1181
|
+
audio/DVI4 'RFC3555
|
1182
|
+
audio/EVRC @evc 'RFC3558
|
1183
|
+
audio/EVRC-QCP 'RFC3625
|
1184
|
+
audio/EVRC0 'RFC3558
|
1185
|
+
audio/G722 'RFC3555
|
1186
|
+
audio/G7221 'RFC3047
|
1187
|
+
audio/G723 'RFC3555
|
1188
|
+
audio/G726-16 'RFC3555
|
1189
|
+
audio/G726-24 'RFC3555
|
1190
|
+
audio/G726-32 'RFC3555
|
1191
|
+
audio/G726-40 'RFC3555
|
1192
|
+
audio/G728 'RFC3555
|
1193
|
+
audio/G729 'RFC3555
|
1194
|
+
audio/G729D 'RFC3555
|
1195
|
+
audio/G729E 'RFC3555
|
1196
|
+
audio/GSM 'RFC3555
|
1197
|
+
audio/GSM-EFR 'RFC3555
|
1198
|
+
audio/L16 @l16 'RFC3555
|
1199
|
+
audio/L20 'RFC3190
|
1200
|
+
audio/L24 'RFC3190
|
1201
|
+
audio/L8 'RFC3555
|
1202
|
+
audio/LPC 'RFC3555
|
1203
|
+
audio/MP4A-LATM 'RFC3016
|
1204
|
+
audio/MPA 'RFC3555
|
1205
|
+
audio/PCMA 'RFC3555
|
1206
|
+
audio/PCMU 'RFC3555
|
1207
|
+
audio/QCELP @qcp 'RFC3555'RFC3625
|
1208
|
+
audio/RED 'RFC3555
|
1209
|
+
audio/SMV @smv 'RFC3558
|
1210
|
+
audio/SMV-QCP 'RFC3625
|
1211
|
+
audio/SMV0 'RFC3558
|
1212
|
+
audio/VDVI 'RFC3555
|
1213
|
+
audio/VMR-WB 'DRAFT:draft-ietf-avt-rtp-vmr-wb,DRAFT:draft-ietf-avt-rtp-vmr-wb-extension
|
1214
|
+
audio/ac3 'RFC4184
|
1215
|
+
audio/amr-wb+ 'DRAFT:draft-ietf-avt-rtp-amrwbplus
|
1216
|
+
audio/basic @au,snd :base64 'RFC2045,RFC2046
|
1217
|
+
audio/clearmode 'RFC4040
|
1218
|
+
audio/dsr-es201108 'RFC3557
|
1219
|
+
audio/dsr-es202050 'RFC4060
|
1220
|
+
audio/dsr-es202211 'RFC4060
|
1221
|
+
audio/dsr-es202212 'RFC4060
|
1222
|
+
audio/iLBC 'RFC3952
|
1223
|
+
audio/mp4 'DRAFT:draft-lim-mpeg4-mime
|
1224
|
+
audio/mpa-robust 'RFC3119
|
1225
|
+
audio/mpeg @mpga,mp2,mp3 :base64 'RFC3003
|
1226
|
+
audio/mpeg4-generic 'RFC3640
|
1227
|
+
audio/parityfec 'RFC3009
|
1228
|
+
audio/prs.sid @sid,psid 'IANA,[Walleij]
|
1229
|
+
audio/rtx 'DRAFT:draft-ietf-avt-rtp-retransmission
|
1230
|
+
audio/t140c 'DRAFT:draft-ietf-avt-audio-t140c
|
1231
|
+
audio/telephone-event 'RFC2833
|
1232
|
+
audio/tone 'RFC2833
|
1233
|
+
audio/vnd.3gpp.iufp 'IANA,[Belling]
|
1234
|
+
audio/vnd.audiokoz 'IANA,[DeBarros]
|
1235
|
+
audio/vnd.cisco.nse 'IANA,[Kumar]
|
1236
|
+
audio/vnd.cmles.radio-events 'IANA,[Goulet]
|
1237
|
+
audio/vnd.cns.anp1 'IANA,[McLaughlin]
|
1238
|
+
audio/vnd.cns.inf1 'IANA,[McLaughlin]
|
1239
|
+
audio/vnd.digital-winds @eol :7bit 'IANA,[Strazds]
|
1240
|
+
audio/vnd.dlna.adts 'IANA,[Heredia]
|
1241
|
+
audio/vnd.everad.plj @plj 'IANA,[Cicelsky]
|
1242
|
+
audio/vnd.lucent.voice @lvp 'IANA,[Vaudreuil]
|
1243
|
+
audio/vnd.nokia.mobile-xmf @mxmf 'IANA,[Nokia Corporation]
|
1244
|
+
audio/vnd.nortel.vbk @vbk 'IANA,[Parsons]
|
1245
|
+
audio/vnd.nuera.ecelp4800 @ecelp4800 'IANA,[Fox]
|
1246
|
+
audio/vnd.nuera.ecelp7470 @ecelp7470 'IANA,[Fox]
|
1247
|
+
audio/vnd.nuera.ecelp9600 @ecelp9600 'IANA,[Fox]
|
1248
|
+
audio/vnd.octel.sbc 'IANA,[Vaudreuil]
|
1249
|
+
audio/vnd.rhetorex.32kadpcm 'IANA,[Vaudreuil]
|
1250
|
+
audio/vnd.sealedmedia.softseal.mpeg @smp3,smp,s1m 'IANA,[Petersen]
|
1251
|
+
audio/vnd.vmx.cvsd 'IANA,[Vaudreuil]
|
1252
|
+
|
1253
|
+
# Registered: image/*
|
1254
|
+
image/cgm 'IANA =Computer Graphics Metafile [Francis]
|
1255
|
+
image/fits 'RFC4047
|
1256
|
+
image/g3fax 'RFC1494
|
1257
|
+
image/gif @gif :base64 'RFC2045,RFC2046
|
1258
|
+
image/ief @ief :base64 'RFC1314 =Image Exchange Format
|
1259
|
+
image/jp2 @jp2 :base64 'IANA,RFC3745
|
1260
|
+
image/jpeg @jpeg,jpg,jpe :base64 'RFC2045,RFC2046
|
1261
|
+
image/jpm @jpm :base64 'IANA,RFC3745
|
1262
|
+
image/jpx @jpx :base64 'IANA,RFC3745
|
1263
|
+
image/naplps 'IANA,[Ferber]
|
1264
|
+
image/png @png :base64 'IANA,[Randers-Pehrson]
|
1265
|
+
image/prs.btif 'IANA,[Simon]
|
1266
|
+
image/prs.pti 'IANA,[Laun]
|
1267
|
+
image/t38 'RFC3362
|
1268
|
+
image/tiff @tiff,tif :base64 'RFC3302 =Tag Image File Format
|
1269
|
+
image/tiff-fx 'RFC3950 =Tag Image File Format Fax eXtended
|
1270
|
+
image/vnd.adobe.photoshop 'IANA,[Scarborough]
|
1271
|
+
image/vnd.cns.inf2 'IANA,[McLaughlin]
|
1272
|
+
image/vnd.djvu @djvu,djv 'IANA,[Bottou]
|
1273
|
+
image/vnd.dwg @dwg 'IANA,[Moline]
|
1274
|
+
image/vnd.dxf 'IANA,[Moline]
|
1275
|
+
image/vnd.fastbidsheet 'IANA,[Becker]
|
1276
|
+
image/vnd.fpx 'IANA,[Spencer]
|
1277
|
+
image/vnd.fst 'IANA,[Fuldseth]
|
1278
|
+
image/vnd.fujixerox.edmics-mmr 'IANA,[Onda]
|
1279
|
+
image/vnd.fujixerox.edmics-rlc 'IANA,[Onda]
|
1280
|
+
image/vnd.globalgraphics.pgb @pgb 'IANA,[Bailey]
|
1281
|
+
image/vnd.microsoft.icon @ico 'IANA,[Butcher]
|
1282
|
+
image/vnd.mix 'IANA,[Reddy]
|
1283
|
+
image/vnd.ms-modi @mdi 'IANA,[Vaughan]
|
1284
|
+
image/vnd.net-fpx 'IANA,[Spencer]
|
1285
|
+
image/vnd.sealed.png @spng,spn,s1n 'IANA,[Petersen]
|
1286
|
+
image/vnd.sealedmedia.softseal.gif @sgif,sgi,s1g 'IANA,[Petersen]
|
1287
|
+
image/vnd.sealedmedia.softseal.jpg @sjpg,sjp,s1j 'IANA,[Petersen]
|
1288
|
+
image/vnd.svf 'IANA,[Moline]
|
1289
|
+
image/vnd.wap.wbmp @wbmp 'IANA,[Stark]
|
1290
|
+
image/vnd.xiff 'IANA,[S.Martin]
|
1291
|
+
|
1292
|
+
# Registered: message/*
|
1293
|
+
message/CPIM 'RFC3862
|
1294
|
+
message/delivery-status 'RFC1894
|
1295
|
+
message/disposition-notification 'RFC2298
|
1296
|
+
message/external-body :8bit 'RFC2046
|
1297
|
+
message/http 'RFC2616
|
1298
|
+
message/news :8bit 'RFC1036,[H.Spencer]
|
1299
|
+
message/partial :8bit 'RFC2046
|
1300
|
+
message/rfc822 :8bit 'RFC2046
|
1301
|
+
message/s-http 'RFC2660
|
1302
|
+
message/sip 'RFC3261
|
1303
|
+
message/sipfrag 'RFC3420
|
1304
|
+
message/tracking-status 'RFC3886
|
1305
|
+
|
1306
|
+
# Registered: model/*
|
1307
|
+
model/iges @igs,iges 'IANA,[Parks]
|
1308
|
+
model/mesh @msh,mesh,silo 'RFC2077
|
1309
|
+
model/vnd.dwf 'IANA,[Pratt]
|
1310
|
+
model/vnd.flatland.3dml 'IANA,[Powers]
|
1311
|
+
model/vnd.gdl 'IANA,[Babits]
|
1312
|
+
model/vnd.gs-gdl 'IANA,[Babits]
|
1313
|
+
model/vnd.gtw 'IANA,[Ozaki]
|
1314
|
+
model/vnd.mts 'IANA,[Rabinovitch]
|
1315
|
+
model/vnd.parasolid.transmit.binary @x_b,xmt_bin 'IANA,[Parasolid]
|
1316
|
+
model/vnd.parasolid.transmit.text @x_t,xmt_txt :quoted-printable 'IANA,[Parasolid]
|
1317
|
+
model/vnd.vtu 'IANA,[Rabinovitch]
|
1318
|
+
model/vrml @wrl,vrml 'RFC2077
|
1319
|
+
|
1320
|
+
# Registered: multipart/*
|
1321
|
+
multipart/alternative :8bit 'RFC2045,RFC2046
|
1322
|
+
multipart/appledouble :8bit 'IANA,[Faltstrom]
|
1323
|
+
multipart/byteranges 'RFC2068
|
1324
|
+
multipart/digest :8bit 'RFC2045,RFC2046
|
1325
|
+
multipart/encrypted 'RFC1847
|
1326
|
+
multipart/form-data 'RFC2388
|
1327
|
+
multipart/header-set 'IANA,[Crocker]
|
1328
|
+
multipart/mixed :8bit 'RFC2045,RFC2046
|
1329
|
+
multipart/parallel :8bit 'RFC2045,RFC2046
|
1330
|
+
multipart/related 'RFC2387
|
1331
|
+
multipart/report 'RFC1892
|
1332
|
+
multipart/signed 'RFC1847
|
1333
|
+
multipart/voice-message 'RFC2421,RFC2423
|
1334
|
+
|
1335
|
+
# Registered: text/*
|
1336
|
+
!text/ecmascript 'DRAFT:draft-hoehrmann-script-types
|
1337
|
+
!text/javascript 'DRAFT:draft-hoehrmann-script-types
|
1338
|
+
text/calendar 'RFC2445
|
1339
|
+
text/css @css :8bit 'RFC2318
|
1340
|
+
text/csv @csv :8bit 'RFC4180
|
1341
|
+
text/directory 'RFC2425
|
1342
|
+
text/dns 'RFC4027
|
1343
|
+
text/enriched 'RFC1896
|
1344
|
+
text/html @html,htm,htmlx,shtml,htx :8bit 'RFC2854
|
1345
|
+
text/parityfec 'RFC3009
|
1346
|
+
text/plain @txt,asc,c,cc,h,hh,cpp,hpp,dat,hlp 'RFC2046,RFC3676
|
1347
|
+
text/prs.fallenstein.rst @rst 'IANA,[Fallenstein]
|
1348
|
+
text/prs.lines.tag 'IANA,[Lines]
|
1349
|
+
text/RED 'RFC4102
|
1350
|
+
text/rfc822-headers 'RFC1892
|
1351
|
+
text/richtext @rtx :8bit 'RFC2045,RFC2046
|
1352
|
+
text/rtf @rtf :8bit 'IANA,[Lindner]
|
1353
|
+
text/rtx 'DRAFT:draft-ietf-avt-rtp-retransmission
|
1354
|
+
text/sgml @sgml,sgm 'RFC1874
|
1355
|
+
text/t140 'RFC4103
|
1356
|
+
text/tab-separated-values @tsv 'IANA,[Lindner]
|
1357
|
+
text/troff @t,tr,roff,troff :8bit 'DRAFT:draft-lilly-text-troff
|
1358
|
+
text/uri-list 'RFC2483
|
1359
|
+
text/vnd.abc 'IANA,[Allen]
|
1360
|
+
text/vnd.curl 'IANA,[Byrnes]
|
1361
|
+
text/vnd.DMClientScript 'IANA,[Bradley]
|
1362
|
+
text/vnd.esmertec.theme-descriptor 'IANA,[Eilemann]
|
1363
|
+
text/vnd.fly 'IANA,[Gurney]
|
1364
|
+
text/vnd.fmi.flexstor 'IANA,[Hurtta]
|
1365
|
+
text/vnd.in3d.3dml 'IANA,[Powers]
|
1366
|
+
text/vnd.in3d.spot 'IANA,[Powers]
|
1367
|
+
text/vnd.IPTC.NewsML '[IPTC]
|
1368
|
+
text/vnd.IPTC.NITF '[IPTC]
|
1369
|
+
text/vnd.latex-z 'IANA,[Lubos]
|
1370
|
+
text/vnd.motorola.reflex 'IANA,[Patton]
|
1371
|
+
text/vnd.ms-mediapackage 'IANA,[Nelson]
|
1372
|
+
text/vnd.net2phone.commcenter.command @ccc 'IANA,[Xie]
|
1373
|
+
text/vnd.sun.j2me.app-descriptor @jad :8bit 'IANA,[G.Adams]
|
1374
|
+
text/vnd.wap.si @si 'IANA,[WAP-Forum]
|
1375
|
+
text/vnd.wap.sl @sl 'IANA,[WAP-Forum]
|
1376
|
+
text/vnd.wap.wml @wml 'IANA,[Stark]
|
1377
|
+
text/vnd.wap.wmlscript @wmls 'IANA,[Stark]
|
1378
|
+
text/xml @xml,dtd :8bit 'RFC3023
|
1379
|
+
text/xml-external-parsed-entity 'RFC3023
|
1380
|
+
vms:text/plain @doc :8bit
|
1381
|
+
|
1382
|
+
# Registered: video/*
|
1383
|
+
video/3gpp @3gp,3gpp 'RFC3839,DRAFT:draft-gellens-mime-bucket
|
1384
|
+
video/3gpp-tt 'DRAFT:draft-ietf-avt-rtp-3gpp-timed-text
|
1385
|
+
video/3gpp2 'DRAFT:draft-garudadri-avt-3gpp2-mime
|
1386
|
+
video/BMPEG 'RFC3555
|
1387
|
+
video/BT656 'RFC3555
|
1388
|
+
video/CelB 'RFC3555
|
1389
|
+
video/DV 'RFC3189
|
1390
|
+
video/H261 'RFC3555
|
1391
|
+
video/H263 'RFC3555
|
1392
|
+
video/H263-1998 'RFC3555
|
1393
|
+
video/H263-2000 'RFC3555
|
1394
|
+
video/H264 'RFC3984
|
1395
|
+
video/JPEG 'RFC3555
|
1396
|
+
video/MJ2 @mj2,mjp2 'RFC3745
|
1397
|
+
video/MP1S 'RFC3555
|
1398
|
+
video/MP2P 'RFC3555
|
1399
|
+
video/MP2T 'RFC3555
|
1400
|
+
video/mp4 'DRAFT:draft-lim-mpeg4-mime
|
1401
|
+
video/MP4V-ES 'RFC3016
|
1402
|
+
video/mpeg @mp2,mpe,mp3g,mpg :base64 'RFC2045,RFC2046
|
1403
|
+
video/mpeg4-generic 'RFC3640
|
1404
|
+
video/MPV 'RFC3555
|
1405
|
+
video/nv 'RFC3555
|
1406
|
+
video/parityfec 'RFC3009
|
1407
|
+
video/pointer 'RFC2862
|
1408
|
+
video/quicktime @qt,mov :base64 'IANA,[Lindner]
|
1409
|
+
video/raw 'RFC4175
|
1410
|
+
video/rtx 'DRAFT:draft-ietf-avt-rtp-retransmission
|
1411
|
+
video/SMPTE292M 'RFC3497
|
1412
|
+
video/vnd.dlna.mpeg-tts 'IANA,[Heredia]
|
1413
|
+
video/vnd.fvt 'IANA,[Fuldseth]
|
1414
|
+
video/vnd.motorola.video 'IANA,[McGinty]
|
1415
|
+
video/vnd.motorola.videop 'IANA,[McGinty]
|
1416
|
+
video/vnd.mpegurl @mxu,m4u :8bit 'IANA,[Recktenwald]
|
1417
|
+
video/vnd.nokia.interleaved-multimedia @nim 'IANA,[Kangaslampi]
|
1418
|
+
video/vnd.objectvideo @mp4 'IANA,[Clark]
|
1419
|
+
video/vnd.sealed.mpeg1 @s11 'IANA,[Petersen]
|
1420
|
+
video/vnd.sealed.mpeg4 @smpg,s14 'IANA,[Petersen]
|
1421
|
+
video/vnd.sealed.swf @sswf,ssw 'IANA,[Petersen]
|
1422
|
+
video/vnd.sealedmedia.softseal.mov @smov,smo,s1q 'IANA,[Petersen]
|
1423
|
+
video/vnd.vivo @viv,vivo 'IANA,[Wolfe]
|
1424
|
+
|
1425
|
+
# Unregistered: application/*
|
1426
|
+
!application/x-troff 'LTSW =use-instead:text/troff
|
1427
|
+
application/x-bcpio @bcpio 'LTSW
|
1428
|
+
application/x-compressed @z,Z :base64 'LTSW
|
1429
|
+
application/x-cpio @cpio :base64 'LTSW
|
1430
|
+
application/x-csh @csh :8bit 'LTSW
|
1431
|
+
application/x-dvi @dvi :base64 'LTSW
|
1432
|
+
application/x-gtar @gtar,tgz,tbz2,tbz :base64 'LTSW
|
1433
|
+
application/x-gzip @gz :base64 'LTSW
|
1434
|
+
application/x-hdf @hdf 'LTSW
|
1435
|
+
application/x-java-archive @jar 'LTSW
|
1436
|
+
application/x-java-jnlp-file @jnlp 'LTSW
|
1437
|
+
application/x-java-serialized-object @ser 'LTSW
|
1438
|
+
application/x-java-vm @class 'LTSW
|
1439
|
+
application/x-latex @ltx,latex :8bit 'LTSW
|
1440
|
+
application/x-mif @mif 'LTSW
|
1441
|
+
application/x-rtf 'LTSW =use-instead:application/rtf
|
1442
|
+
application/x-sh @sh 'LTSW
|
1443
|
+
application/x-shar @shar 'LTSW
|
1444
|
+
application/x-stuffit @sit :base64 'LTSW
|
1445
|
+
application/x-sv4cpio @sv4cpio :base64 'LTSW
|
1446
|
+
application/x-sv4crc @sv4crc :base64 'LTSW
|
1447
|
+
application/x-tar @tar :base64 'LTSW
|
1448
|
+
application/x-tcl @tcl :8bit 'LTSW
|
1449
|
+
application/x-tex @tex :8bit
|
1450
|
+
application/x-texinfo @texinfo,texi :8bit
|
1451
|
+
application/x-troff-man @man :8bit 'LTSW
|
1452
|
+
application/x-troff-me @me 'LTSW
|
1453
|
+
application/x-troff-ms @ms 'LTSW
|
1454
|
+
application/x-ustar @ustar :base64 'LTSW
|
1455
|
+
application/x-wais-source @src 'LTSW
|
1456
|
+
mac:application/x-mac @bin :base64
|
1457
|
+
*!application/cals1840 'LTSW =use-instead:application/cals-1840
|
1458
|
+
*!application/remote_printing 'LTSW =use-instead:application/remote-printing
|
1459
|
+
*!application/x-u-star 'LTSW =use-instead:application/x-ustar
|
1460
|
+
*!application/x400.bp 'LTSW =use-instead:application/x400-bp
|
1461
|
+
*application/acad 'LTSW
|
1462
|
+
*application/clariscad 'LTSW
|
1463
|
+
*application/drafting 'LTSW
|
1464
|
+
*application/dxf 'LTSW
|
1465
|
+
*application/excel @xls,xlt 'LTSW
|
1466
|
+
*application/fractals 'LTSW
|
1467
|
+
*application/i-deas 'LTSW
|
1468
|
+
*application/macbinary 'LTSW
|
1469
|
+
*application/netcdf @nc,cdf 'LTSW
|
1470
|
+
*application/powerpoint @ppt,pps,pot :base64 'LTSW
|
1471
|
+
*application/pro_eng 'LTSW
|
1472
|
+
*application/set 'LTSW
|
1473
|
+
*application/SLA 'LTSW
|
1474
|
+
*application/solids 'LTSW
|
1475
|
+
*application/STEP 'LTSW
|
1476
|
+
*application/vda 'LTSW
|
1477
|
+
*application/word @doc,dot 'LTSW
|
1478
|
+
|
1479
|
+
# Unregistered: audio/*
|
1480
|
+
audio/x-aiff @aif,aifc,aiff :base64
|
1481
|
+
audio/x-midi @mid,midi,kar :base64
|
1482
|
+
audio/x-pn-realaudio @rm,ram :base64
|
1483
|
+
audio/x-pn-realaudio-plugin @rpm
|
1484
|
+
audio/x-realaudio @ra :base64
|
1485
|
+
audio/x-wav @wav :base64
|
1486
|
+
|
1487
|
+
# Unregistered: image/*
|
1488
|
+
*image/vnd.dgn @dgn =use-instead:image/x-vnd.dgn
|
1489
|
+
image/x-bmp @bmp
|
1490
|
+
image/x-cmu-raster @ras
|
1491
|
+
image/x-paintshoppro @psp,pspimage :base64
|
1492
|
+
image/x-pict
|
1493
|
+
image/x-portable-anymap @pnm :base64
|
1494
|
+
image/x-portable-bitmap @pbm :base64
|
1495
|
+
image/x-portable-graymap @pgm :base64
|
1496
|
+
image/x-portable-pixmap @ppm :base64
|
1497
|
+
image/x-rgb @rgb :base64
|
1498
|
+
image/x-targa @tga
|
1499
|
+
image/x-vnd.dgn @dgn
|
1500
|
+
image/x-win-bmp
|
1501
|
+
image/x-xbitmap @xbm :7bit
|
1502
|
+
image/x-xbm @xbm :7bit
|
1503
|
+
image/x-xpixmap @xpm :8bit
|
1504
|
+
image/x-xwindowdump @xwd :base64
|
1505
|
+
*!image/cmu-raster =use-instead:image/x-cmu-raster
|
1506
|
+
*!image/vnd.net.fpx =use-instead:image/vnd.net-fpx
|
1507
|
+
*image/bmp @bmp
|
1508
|
+
*image/targa @tga
|
1509
|
+
|
1510
|
+
# Unregistered: multipart/*
|
1511
|
+
multipart/x-gzip
|
1512
|
+
multipart/x-mixed-replace
|
1513
|
+
multipart/x-tar
|
1514
|
+
multipart/x-ustar
|
1515
|
+
multipart/x-www-form-urlencoded
|
1516
|
+
multipart/x-zip
|
1517
|
+
*!multipart/parallel =use-instead:multipart/parallel
|
1518
|
+
|
1519
|
+
# Unregistered: text/*
|
1520
|
+
*text/comma-separated-values @csv :8bit
|
1521
|
+
*text/vnd.flatland.3dml =use-instead:model/vnd.flatland.3dml
|
1522
|
+
text/x-vnd.flatland.3dml =use-instead:model/vnd.flatland.3dml
|
1523
|
+
text/x-setext @etx
|
1524
|
+
text/x-vcalendar @vcs :8bit
|
1525
|
+
text/x-vcard @vcf :8bit
|
1526
|
+
text/x-yaml @yaml,yml :8bit
|
1527
|
+
|
1528
|
+
# Unregistered: video/*
|
1529
|
+
*video/dl @dl :base64
|
1530
|
+
*video/gl @gl :base64
|
1531
|
+
video/x-msvideo @avi :base64
|
1532
|
+
video/x-sgi-movie @movie :base64
|
1533
|
+
|
1534
|
+
# Unregistered: other/*
|
1535
|
+
x-chemical/x-pdb @pdb
|
1536
|
+
x-chemical/x-xyz @xyz
|
1537
|
+
x-conference/x-cooltalk @ice
|
1538
|
+
x-drawing/dwf @dwf
|
1539
|
+
x-world/x-vrml @wrl,vrml
|
1540
|
+
MIME_TYPES
|
1541
|
+
|
1542
|
+
_re = %r{
|
1543
|
+
^
|
1544
|
+
([*])? # 0: Unregistered?
|
1545
|
+
(!)? # 1: Obsolete?
|
1546
|
+
(?:(\w+):)? # 2: Platform marker
|
1547
|
+
#{MIME::Type::MEDIA_TYPE_RE} # 3,4: Media type
|
1548
|
+
(?:\s@([^\s]+))? # 5: Extensions
|
1549
|
+
(?:\s:(#{MIME::Type::ENCODING_RE}))? # 6: Encoding
|
1550
|
+
(?:\s'(.+))? # 7: URL list
|
1551
|
+
(?:\s=(.+))? # 8: Documentation
|
1552
|
+
$
|
1553
|
+
}x
|
1554
|
+
|
1555
|
+
data_mime_type.each do |i|
|
1556
|
+
item = i.chomp.strip.gsub(%r{#.*}o, '')
|
1557
|
+
next if item.empty?
|
1558
|
+
|
1559
|
+
m = _re.match(item).captures
|
1560
|
+
|
1561
|
+
unregistered, obsolete, platform, mediatype, subtype, extensions,
|
1562
|
+
encoding, urls, docs = *m
|
1563
|
+
|
1564
|
+
extensions &&= extensions.split(/,/)
|
1565
|
+
urls &&= urls.split(/,/)
|
1566
|
+
|
1567
|
+
mime_type = MIME::Type.new("#{mediatype}/#{subtype}") do |t|
|
1568
|
+
t.extensions = extensions
|
1569
|
+
t.encoding = encoding
|
1570
|
+
t.system = platform
|
1571
|
+
t.obsolete = obsolete
|
1572
|
+
t.registered = false if unregistered
|
1573
|
+
t.docs = docs
|
1574
|
+
t.url = urls
|
1575
|
+
end
|
1576
|
+
|
1577
|
+
MIME::Types.add_type_variant(mime_type)
|
1578
|
+
MIME::Types.index_extensions(mime_type)
|
1579
|
+
MIME::Types.simplified_extensions(mime_type)
|
1580
|
+
end
|
1581
|
+
|
1582
|
+
_re = nil
|
1583
|
+
data_mime_type = nil
|