87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/action_dispatch/http/mime_type.rb', line 87
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.ends_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
|