Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 68398 invoked from network); 2 Feb 2009 09:42:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Feb 2009 09:42:45 -0000 Received: (qmail 84503 invoked by uid 500); 2 Feb 2009 09:42:44 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 84470 invoked by uid 500); 2 Feb 2009 09:42:44 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 84459 invoked by uid 99); 2 Feb 2009 09:42:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Feb 2009 01:42:44 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of b.candler@pobox.com designates 208.72.237.25 as permitted sender) Received: from [208.72.237.25] (HELO sasl.smtp.pobox.com) (208.72.237.25) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Feb 2009 09:42:34 +0000 Received: from localhost.localdomain (unknown [127.0.0.1]) by b-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTP id 390922A47B for ; Mon, 2 Feb 2009 04:42:09 -0500 (EST) Received: from mappit (unknown [80.45.95.114]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by b-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTPSA id C01722A47A for ; Mon, 2 Feb 2009 04:42:08 -0500 (EST) Received: from brian by mappit with local (Exim 4.69) (envelope-from ) id 1LTvJf-0006l7-5l for user@couchdb.apache.org; Mon, 02 Feb 2009 09:42:07 +0000 Date: Mon, 2 Feb 2009 09:42:07 +0000 From: Brian Candler To: user@couchdb.apache.org Subject: Default response is text/plain Message-ID: <20090202094207.GA25494@uk.tiscali.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Pobox-Relay-ID: C29218B4-F10D-11DD-8398-F63E8D1D4FD0-28021239!a-sasl-quonix.pobox.com X-Virus-Checked: Checked by ClamAV on apache.org I was going to post this on JIRA but thought I'd better raise it here first, in case this is intentional behaviour. By default, all Couchdb responses have Content-Type: text/plain rather than application/json - observed using tcpdump on a ruby app using couch-potato, and easily replicated using telnet. $ telnet localhost 5984 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET /test_suite_db HTTP/1.0 HTTP/1.0 200 OK Server: CouchDB/0.9.0a739811-incubating (Erlang OTP/R12B) Date: Mon, 02 Feb 2009 09:31:36 GMT Content-Type: text/plain;charset=utf-8 <<<<<<<< Content-Length: 171 Cache-Control: must-revalidate {"db_name":"test_suite_db","doc_count":1,"doc_del_count":1,"update_seq":7,"purge_seq":0,"compact_running":false,"disk_size":15755,"instance_start_time":"1233566693355400"}Connection closed by foreign host. However, if you explicitly ask for application/json with an Accept: header, you get that Content-Type instead. $ telnet localhost 5984 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET /test_suite_db HTTP/1.0 Accept: application/json HTTP/1.0 200 OK Server: CouchDB/0.9.0a739811-incubating (Erlang OTP/R12B) Date: Mon, 02 Feb 2009 09:32:03 GMT Content-Type: application/json <<<<<<<< Content-Length: 171 Cache-Control: must-revalidate {"db_name":"test_suite_db","doc_count":1,"doc_del_count":1,"update_seq":7,"purge_seq":0,"compact_running":false,"disk_size":15755,"instance_start_time":"1233566693355400"}Connection closed by foreign host. This seems odd behaviour to me. The "negotiated" content is no different, and the response clearly *is* application/json, whether or not you provide an Accept: header. Is this a workaround for some client bug? Or to make Couchdb work better with browsers for manual interaction? Now, as it happens: couch-potato/couchrest/rest-client is actually sending Accept: application/xml and the response which comes back is Content-Type: text/plain;charset=utf-8 Of course, the client stack is requesting the wrong media type entirely, but under this circumstance I'd still expect Couchdb to say that the response is application/json rather than text/plain, as being a more accurate description of what has been returned. So my suggested behaviour would be: only return test/plain if the Accept: header is present, *and* it contains text/plain, *and* this is higher priority than application/json (if that is present too). Otherwise return application/json. But as I say, maybe this has been discussed before and the current behaviour is entirely intentional. Thanks, Brian.