Which Java libraries do HTTP Accept Header Parsing?

Have a look at the HttpClient Util.parseHeader method.


Edit: (trying to make this answer worth being accepted post-factum)

The spring framework provides this functionality within its MediaType component.

If you are already using Spring MVC you can simply request for a @RequestHeader-annotated parameter of type HttpHeaders and access the list of accepted media types by simply calling HttpHeaders.getAccept().


You should read this article : http://www.xml.com/pub/a/2005/06/08/restful.html

The article uses Python but it's not a problem : at the end, the following link is shared : http://code.google.com/p/mimeparse

As you can see, "mimeparse" is :

Basic functions for handling mime-types in Erlang, JavaScript, Perl, PHP, Python, Ruby, Java

According to the home page :

List<String> mimeTypesSupported = Arrays.asList(StringUtils.split(
            "application/xbel+xml,text/xml", ','));
String bestMatch = MIMEParse.bestMatch(mimeTypesSupported, "text/*;q=0.5,*/*;q=0.1");