http://code.google.com/p/mimeparse/source/browse/trunk/mimeparse.rb
The entire lib is 216 lines with tests and supports parsing complex
Accept headers with, e.g., q= values and other parameters. There's also
"best_match" implementation:
irb> best_match(["application/xbel+xml", "text/xml"],
"text/*;q=0.5,*/*; q=0.1")
=> "text/xml"
I'll work with bct to get a patch together and open a ticket. In the
meantime, any thoughts?
Thanks
--
Ryan http://tomayko.com/about
Some of that code could be generalized to also handle Accept-Encoding.
I took a look at MIMEParse when I wrote Rack::Deflater and IIRC all of
the functions are implemented in terms of parse_mime_type which
understands strings like "text/html" but not encoding names like
"gzip". If that could be parameterized, then I think most of
Rack::Utils.select_best_encoding could be thrown out.
Cheers,
Christoffer Sawicki
http://vemod.net/
> I'll work with bct to get a patch together and open a ticket. In the
> meantime, any thoughts?
+1, I have a stipped down version in coset, but let's import the whole
thing if possible.
--
Christian Neukirchen <chneuk...@gmail.com> http://chneukirchen.org