[Jersey] Content negotiation surprises

From: Daniel Larsson <>
Date: Tue, 14 Feb 2012 17:53:19 +0100

Hi all,

Due to IE's brain dead Accept header, I've set server side quality on
HTML formats, like so:

   @Produces(MediaType.TEXT_HTML + ";qs=4")

I was using jQuery.getJSON today, accessing a resource, which also has
a @GET annotated method returning 'application/json', without any qs
parameter. Apparently jQuery sets the Accept header to
"application/json, text/javascript, */*; q=0.01" in this case. This,
somewhat surprisingly to me, caused the HTML GET method to be called.
The cause of this is HttpMethodRule.getSpecificAcceptableMediaTypes,
which seems to pick the first match, in this case text/html. I
expected that both the 'qs' and 'q' parameters combined would
determine which media type to prefer, i.e. the highest of 'q * qs'.

Is this the intended behaviour, and is there a particular rationale for it?