Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 99523 invoked from network); 11 Jul 2009 17:00:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Jul 2009 17:00:58 -0000 Received: (qmail 97938 invoked by uid 500); 11 Jul 2009 17:01:08 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 97856 invoked by uid 500); 11 Jul 2009 17:01:07 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 97847 invoked by uid 99); 11 Jul 2009 17:01:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Jul 2009 17:01:07 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Jul 2009 17:01:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6AB3B23888D1; Sat, 11 Jul 2009 17:00:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r793205 - in /couchdb/trunk: share/www/script/test/attachments.js src/couchdb/couch_httpd_db.erl Date: Sat, 11 Jul 2009 17:00:43 -0000 To: commits@couchdb.apache.org From: jan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090711170043.6AB3B23888D1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jan Date: Sat Jul 11 17:00:42 2009 New Revision: 793205 URL: http://svn.apache.org/viewvc?rev=793205&view=rev Log: send Location header for new or updated attachments Modified: couchdb/trunk/share/www/script/test/attachments.js couchdb/trunk/src/couchdb/couch_httpd_db.erl Modified: couchdb/trunk/share/www/script/test/attachments.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/attachments.js?rev=793205&r1=793204&r2=793205&view=diff ============================================================================== --- couchdb/trunk/share/www/script/test/attachments.js (original) +++ couchdb/trunk/share/www/script/test/attachments.js Sat Jul 11 17:00:42 2009 @@ -58,6 +58,10 @@ headers:{"Content-Type": "text/plain;charset=utf-8"} }); T(xhr.status == 201); + TEquals("/bin_doc2/foo2.txt", + xhr.getResponseHeader("Location").substr(-18), + "should return Location header to newly created or updated attachment"); + var rev = JSON.parse(xhr.responseText).rev; binAttDoc2 = db.open("bin_doc2"); @@ -78,7 +82,8 @@ // test with rev, should not fail var xhr = CouchDB.request("DELETE", "/test_suite_db/bin_doc2/foo2.txt?rev=" + rev); T(xhr.status == 200); - + TEquals(null, xhr.getResponseHeader("Location"), + "should not return Location header on DELETE request"); // test binary data var bin_data = "JHAPDO*AU£PN ){(3u[d 93DQ9¡€])} ææøo'∂ƒæ≤çæππ•¥∫¶®#†π¶®¥π€ª®˙π8np"; Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=793205&r1=793204&r2=793205&view=diff ============================================================================== --- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Sat Jul 11 17:00:42 2009 @@ -842,7 +842,19 @@ attachments = NewAttachment ++ proplists:delete(FileName, Attachments) }, {ok, UpdatedRev} = couch_db:update_doc(Db, DocEdited, []), - send_json(Req, case Method of 'DELETE' -> 200; _ -> 201 end, {[ + #db{name=DbName} = Db, + + {Status, Headers} = case Method of + 'DELETE' -> + {200, []}; + _ -> + {201, [{"Location", absolute_uri(Req, "/" ++ + binary_to_list(DbName) ++ "/" ++ + binary_to_list(DocId) ++ "/" ++ + binary_to_list(FileName) + )}]} + end, + send_json(Req,Status, Headers, {[ {ok, true}, {id, DocId}, {rev, couch_doc:rev_to_str(UpdatedRev)}