You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Henry Saginor (JIRA)" <ji...@apache.org> on 2019/03/15 16:09:00 UTC

[jira] [Updated] (OAK-8135) Oak http service may not select correct mime type if multiple are specified in Accept header

     [ https://issues.apache.org/jira/browse/OAK-8135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henry Saginor updated OAK-8135:
-------------------------------
    Description: 
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 firs 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.MediaType.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}

  was:
Steps to reproduce:
With HTTPie
> http -j -b -a admin:admin localhost:8080
or with cUrl
> curl -u admin:admin http://localhost:8080 --header "Accept: application/json, */*"

In both of the above cases http service selects the firs 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.MediaType.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}


> 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
>
> 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 firs 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.MediaType.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)