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

Sean Lang commented on COUCHDB-2570:
------------------------------------

If the browser is sending `Accept:*/*`, then you can return 
`application/json`... the browser is saying that it supports any content type. 
And sending JSON as text/plain is harmful because the browser will display it 
as text, rather than doing what it is supposed to (in this case: saving the 
file as a download, or in my case: displaying it as formatted JSON).

CouchDB doesn't get to decide how the browser should be handling JSON responses 
- the browser (and therefore the user) decides that. If the browser turns it 
into a file download, then that's probably because minified JSON is useless to 
read in a browser (if you don't have something like JSONView installed) and it 
should be opened in an external program.

And `test/plain` isn't even the representation you're returning. If you 
actually wanted to return text/plain, you should convert the response into 
something like YAML or at least pretty-printed JSON... Not that this would be a 
good solution, but at least then you could sorta consider it text/plain, unlike 
the blob of JSON I get right now, which is nigh unreadable for humans.

> Using JSONView and similar plugins that teaches browsers to send Accept 
> header with application/json MIME type is optional feature that is not 
> available for all users.

First, the browser shouldn't need to send `application/json` - it already sent 
`*/*`, which means `application/json` is accepted. Second, displaying JSON in 
the browser _is_ an optional feature. I do think that browsers should support 
displaying JSON and other content types in meaningful ways (which is why I use 
things like JSONView), but it's certainly not a requirement.

> All Docs reports wrong content-type
> -----------------------------------
>
>                 Key: COUCHDB-2570
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-2570
>             Project: CouchDB
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>            Reporter: Dominic Barnes
>
> On {{1.6.1}}, the {{/:db/_all_docs}} endpoint only reports {{Content-Type: 
> text/plain}} rather than {{application/json}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to