jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: [jax-rs-spec users] Re: Re: Re: Matching Algorithm in Spec

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Tue, 9 Apr 2013 09:45:14 +0100

Hi
On 08/04/13 18:15, Santiago Pericas-Geertsen wrote:
>
> On Apr 8, 2013, at 12:36 PM, Sergey Beryozkin<sberyozkin_at_talend.com> wrote:
>
>> Hi Santiago
>>
>>>>>>> Here a few interesting cases:
>>>>>>>
>>>>>>> (I) Request (Accept: text/plain, application/xml)
>>>>>>>
>>>>>>> Resource {
>>>>>>> @GET @Produces("text/*") m1() { ... }
>>>>>>> @GET @Produces("application/xml") m2() { ... }
>>>>>>> }
>>>>>>>
>>>>>>> Which method should be matched in this case?
>>>>>>>
>>>>>>> (II) Same as (I) but with q=0.8 in Accept:
>>>>>>>
>>>>>>> Request (Accept: text/plain, application/xml;q=0.8)
>>>>>>>
>>>>>>> What about in this case?
>>>
>>> It does not in any way complicate the algorithm implementation (it obviously doesn't need to follow the formalization in the spec). It does, however, resolve a number of ambiguous cases involving _incompatible_ types that do not follow the simple m/n> m/*> */* rule (for a fixed m and n).
>>
>> Is there any chance that you can give me a favor and 'apply' a spec text in this thread to cases (I), (II) and one more case involving incompatible types (please choose at your discretion) ?
>
> Sure.
>
> (I) - Step 3a has M = { m1, m2 }
> - There's no t or C_M in this case (it's a GET!)
> - A = { text/plain, application/xml }
> We are looking for the max according to>= as follows:
>
> max>= {
> S(text/plain, text/*), S(application/xml, text/*), // for m1
> S(text/plain, application/xml), S(application/xml, application/xml) // for m2
> } =
> max>= {
> text/plain;q=1;qs=1;d=1, \bottom, // for m1
> \bottom, application/xml;q=1;qs=1;d=0 // for m2
> } =
> application/xml;q=1;qs=1;d=0 // wins because of its value of d
>
> (II) Same as (i) except that in this case 'text/plain;q=1;qs=1;d=1' wins because its q is> than 0.8.
>
> Hope this helps.
>
It does.
IMHO, it is useful for the implementers to double check that the
formalized approach produces the same result as the one deemed to be
equivalent in the actual implementation; I was able to do that easily
enough when working on a "setting the correct response type" task, but
thought that I'd rather get some clarifications on 3.7.2 first.

Thanks, Sergey

> -- Santiago
>
>
>
>
>