def self.parse_accept_header(value)
chunks = value.split(',', -1).collect { |v| v.strip }
accept = []
chunks.each { |chunk|
parts = chunk.split(";", -1).collect { |s| s.strip }
mtype = parts.shift
if mtype.index('/').nil?
next
end
main, sub = mtype.split('/', 2)
q = nil
parts.each { |ext|
if !ext.index('=').nil?
k, v = ext.split('=', 2)
if k == 'q'
q = v.to_f
end
end
}
q = 1.0 if q.nil?
accept << [q, main, sub]
}
accept.sort!
accept.reverse!
return accept.collect { |q, main, sub| [main, sub, q] }
end