Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Request Object does not handle qvalues for media types in Accept headers #14

Open
odaata opened this issue Mar 26, 2013 · 4 comments

Comments

@odaata
Copy link

odaata commented Mar 26, 2013

When using the produces annotation to distinguish between two XQuery functions that share the same path annotation, the RestXQ servlet does not handle qvalue preferences for multiple media types in the HTTP Accept header correctly.

For example, Firefox sends the following default header when a user makes a request (e.g. via the URL bar):

text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Using the two XQuery functions below as an example and assuming the Firefox Accept header above, the second function should be called by RestXQ, since "text/html" has a qvalue of 1 in the Accept header, but instead, the first function is called.

declare
    %rest:GET
    %rest:path("/{$app}/{$resource}")
    %rest:produces("application/xml")
function...

declare
    %rest:GET
    %rest:path("/{$app}/{$resource}")
    %rest:produces("text/html")
function...
@apb2006
Copy link

apb2006 commented Mar 26, 2013

FYI The BaseX RESTXQ implementation is not currently handling quality factors
BaseXdb/basex#563

@ChristianGruen
Copy link
Member

The algorithm presented in #1 may need to be extend to also handle quality factors. Would someone be interested in drafting a proposal?

@apb2006
Copy link

apb2006 commented Jun 22, 2013

Why not just use the JAX-RS spec, 3.7.2 Request Matching step 3b?

Determining the best matching media types follows the general rule: n/m > n/* > /, i.e. a method that explicitly consumes the request media type or produces one of the requested media types is sorted before a method that consumes or produces /. Quality parameter values in the accept header are also considered such that methods that produce media types with a higher acceptable q-value are sorted ahead of those with a lower acceptable q-value (i.e. n/m;q=1.0 > n/m;q=0.7) - see section 14.1 of [4] for more details.

https://jsr311.java.net/nonav/releases/1.0/spec/index.html#x3-340003.7.2

@ChristianGruen
Copy link
Member

@apb2006: That was a good hint. My experience is that the JAX-RS way of doing it is compliant with RESTXQ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants