users@jax-rs-spec.java.net

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

From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
Date: Mon, 8 Apr 2013 13:15:45 -0400

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.

-- Santiago