couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcello Nuccio (JIRA)" <>
Subject [jira] [Commented] (COUCHDB-1175) Improve content type negotiation for couchdb JSON responses
Date Fri, 17 Jun 2011 15:22:47 GMT


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:


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:
>             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
> We should follow the standard.

This message is automatically generated by JIRA.
For more information on JIRA, see:


View raw message