[
https://issues.apache.org/jira/browse/COUCHDB-1175?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13051132#comment-13051132
]
Marcello Nuccio commented on COUCHDB-1175:
------------------------------------------
>From Robert Newson response on the ML:
The current logic for CouchDB 1.1.0 is this:
1) If the client accepts "application/json" then respond with 401 and
content-type "application/json" (i.e, a normal HTTP/REST response.
2) if the client accepts "text/html" then respond with a 302 to the
authentication_redirect url.
This is from couch_httpd:error_headers/4.
The problem of this logic is that it does not work with browsers like Firefox4,
because they accept "*/*" which includes "application/json", so the "text/html"
case is never triggered.
IMHO the solution is to take "q" parameter into account, and give precedence to
"text/html" if it has an higher value of "q".
e.g., Firefox4 uses the following Accept header:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Here "text/html" has "q=1.0" (the default), so it should have precedence over
"application/json" which has "q=0.8" (from "*/*").
This should solve the "browser use-case", since browsers should always give to
"text/html" higher values of "q".
> Improve content type negotiation for couchdb JSON responses
> -----------------------------------------------------------
>
> Key: COUCHDB-1175
> URL: https://issues.apache.org/jira/browse/COUCHDB-1175
> Project: CouchDB
> Issue Type: Improvement
> Affects Versions: 1.0.2
> Reporter: Robert Newson
> Fix For: 1.1, 1.2
>
>
> Currently we ignore qvalues when negotiation between 'application/json' and
> 'text/plain' when returning JSON responses.
> Specifically, we test directly for 'application/json' or 'text/plain' in the
> Accept header. Different branches have different bugs, though. Trunk returns
> 'application/json' if 'application/json' is present at all, even if it's less
> preferred than 'text/plain' when qvalues are accounted for.
> We should follow the standard.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira