users@jersey.java.net

[Jersey] Re: Conneg with Accept parameters

From: Jan Algermissen <algermissen1971_at_me.com>
Date: Tue, 05 Apr 2011 17:09:49 +0200

On Apr 5, 2011, at 3:34 PM, Tim Williams wrote:

> On Tue, Apr 5, 2011 at 8:34 AM, algermissen1971 <algermissen1971_at_mac.com> wrote:
>>
>>
>> On 05 Apr, 2011,at 02:27 PM, Tim Williams <williamstw_at_gmail.com> wrote:
>>
>> Does Jersey (or JAX-RS) support content negotiation based on Accept
>> params[1]? Something similar to the qs support...
>>
>> @GET
>> @Produces("application/myformat+xml; foo=bar")
>> public Object getBarProfile() {
>> ...
>> }
>>
>> @GET
>> @Produces("application/myformat+xml; foo=baz")
>> public Object getBazProfile() {
>> ...
>> }
>>
>> Or any pointers to how one might extend it to get this behavior?
>>
>>
>> Do you intend to distinguish between the two? That would be wrong, because
>> parameters (other than q) should not be considered in conneg.
>
> Hi Jan, thanks for your response. I wonder if you can point me to a
> reference for it being "wrong" as that wasn't my understanding of
> 2616? Why would it be defined as a part of the Accept header if it
> weren't to be considered?

Sorry, maybe that was a bit unclear. I meant that media type equality matching must ignore the parameters because they are per-specification insignificant to the meaning of the media type name.

You are right that it makes sense to use parameters in the accept header to indicate client preferences (there are various specs out there that deal with profile or feature negotiation).

Jan


>
> Apart from content negotiation, for practical purposes it seems useful
> to allow dispatching internally to particular methods based on a
> parameter. In other words, suppose the client used the quality
> indicator to declare their preference, one may still want to dispatch
> to different methods based on the parameters, in implementing
> something like the example from the spec:
>
> text/html;level=1 = 1
> text/html = 0.7
> text/plain = 0.3
>
> image/jpeg = 0.5
> text/html;level=2 = 0.4
> text/html;level=3 = 0.7
>
> Their was support for using parameters in this way on rest-discuss
> some time ago[1] and I gathered that you'd even had experience using
> it in this way[2].
>
> --tim
>
> [1] - http://tech.groups.yahoo.com/group/rest-discuss/message/13218
> [2] - http://tech.groups.yahoo.com/group/rest-discuss/message/13223