jackrabbit-oak-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julian Reschke (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OAK-8135) Oak http service may not select correct mime type if multiple are specified in Accept header
Date Wed, 20 Mar 2019 19:56:00 GMT

    [ https://issues.apache.org/jira/browse/OAK-8135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16797497#comment-16797497
] 

Julian Reschke commented on OAK-8135:
-------------------------------------

FWIW,

{noformat}
Accept: application/json, */*
{noformat}

gives both ("application/json" and "*/*") the same weight, so the server would be entirely
correct to return whatever it prefers.

> Oak http service may not select correct mime type if multiple are specified in Accept
header
> --------------------------------------------------------------------------------------------
>
>                 Key: OAK-8135
>                 URL: https://issues.apache.org/jira/browse/OAK-8135
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>            Reporter: Henry Saginor
>            Priority: Major
>         Attachments: MediaRange.patch
>
>
> Steps to reproduce:
>  With HTTPie
> {code:java}
> > http -j -b -a admin:admin localhost:8080{code}
> or with cUrl
> {code:java}
> > curl -u admin:admin http://localhost:8080 --header "Accept: application/json, */*"{code}
> In both of the above cases http service selects the first available representation (aka
HTML) based on "**/**" instead of more specific JSON.
> I think one possible fix is to by default assign higher weight to more specific mime
types when Accept header is parsed in org.apache.jackrabbit.oak.http.MediaRange.parse
> For example replacing return statement in above method with the following fixed this
bug in my testing:
> {code:java}
> double defaultQ = 3.0;
> if("*/*".equals(type.getType())) {
>     defaultQ = 1.0;
> } else if("*".equals(type.getSubtype())) {
>     defaultQ = 2.0;
> }
>         
> return new MediaRange(type, defaultQ);
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message