106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/action_dispatch/http/mime_type.rb', line 106
def self.sort!(list)
list.sort!
text_xml_idx = find_item_by_name list, "text/xml"
app_xml_idx = find_item_by_name list, Mime[:xml].to_s
if text_xml_idx && app_xml_idx
app_xml = list[app_xml_idx]
text_xml = list[text_xml_idx]
app_xml.q = [text_xml.q, app_xml.q].max if app_xml_idx > text_xml_idx list[app_xml_idx], list[text_xml_idx] = text_xml, app_xml
app_xml_idx, text_xml_idx = text_xml_idx, app_xml_idx
end
list.delete_at(text_xml_idx) elsif text_xml_idx
list[text_xml_idx].name = Mime[:xml].to_s
end
if app_xml_idx
app_xml = list[app_xml_idx]
idx = app_xml_idx
while idx < list.length
type = list[idx]
break if type.q < app_xml.q
if type.name.end_with? "+xml"
list[app_xml_idx], list[idx] = list[idx], app_xml
app_xml_idx = idx
end
idx += 1
end
end
list.map! { |i| Mime::Type.lookup(i.name) }.uniq!
list
end
|