You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Robert Newson (JIRA)" <ji...@apache.org> on 2011/07/07 19:43:17 UTC

[jira] [Commented] (COUCHDB-1175) Improve content type negotiation for couchdb JSON responses

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

Robert Newson commented on COUCHDB-1175:
----------------------------------------

It turns out that browsers typically send horribly broken Accept lines, so 'proper' content type negotiation will not work out in practice.

I propose this, inspired by this post (https://github.com/rails/rails/commit/1310231c15742bf7d99e2f143d88b383c32782d3);

1) if the Accept line is *exactly* 'application/json', we return json (and 401's instead of 302's).
2) otherwise we assume the request is from a browser and return html (and 302's instead of 401's).

The version of jquery we use does *not* append '*/*' so the above ought to work.

Feedback is needed, please.


> 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
>            Assignee: Robert Newson
>            Priority: Blocker
>             Fix For: 1.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