Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 22125 invoked from network); 4 Feb 2010 09:56:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Feb 2010 09:56:19 -0000 Received: (qmail 86833 invoked by uid 500); 4 Feb 2010 09:56:18 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 86760 invoked by uid 500); 4 Feb 2010 09:56:17 -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 86750 invoked by uid 99); 4 Feb 2010 09:56:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Feb 2010 09:56:17 +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; Thu, 04 Feb 2010 09:56:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9FD8A23889CB; Thu, 4 Feb 2010 09:55:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r906423 - in /couchdb/trunk: share/www/script/test/show_documents.js src/couchdb/couch_httpd_show.erl Date: Thu, 04 Feb 2010 09:55:56 -0000 To: commits@couchdb.apache.org From: benoitc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100204095556.9FD8A23889CB@eris.apache.org> Author: benoitc Date: Thu Feb 4 09:55:56 2010 New Revision: 906423 URL: http://svn.apache.org/viewvc?rev=906423&view=rev Log: fix COUCHDB-638. Modified: couchdb/trunk/share/www/script/test/show_documents.js couchdb/trunk/src/couchdb/couch_httpd_show.erl Modified: couchdb/trunk/share/www/script/test/show_documents.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/show_documents.js?rev=906423&r1=906422&r2=906423&view=diff ============================================================================== --- couchdb/trunk/share/www/script/test/show_documents.js (original) +++ couchdb/trunk/share/www/script/test/show_documents.js Thu Feb 4 09:55:56 2010 @@ -121,6 +121,9 @@ provides("foo", function() { return "foofoo"; }); + }), + "withSlash": stringFun(function(doc, req) { + return { json: doc } }) } }; @@ -343,4 +346,9 @@ xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/json/foo"); TEquals(1, JSON.parse(xhr.responseText)._conflicts.length); + var doc3 = {_id:"a/b/c", a:1}; + db.save(doc3); + xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/withSlash/a/b/c"); + T(xhr.status == 200); + }; Modified: couchdb/trunk/src/couchdb/couch_httpd_show.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_show.erl?rev=906423&r1=906422&r2=906423&view=diff ============================================================================== --- couchdb/trunk/src/couchdb/couch_httpd_show.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd_show.erl Thu Feb 4 09:55:56 2010 @@ -21,11 +21,15 @@ [send_json/2,send_json/3,send_json/4,send_method_not_allowed/2, start_json_response/2,send_chunk/2,last_chunk/1,send_chunked_error/2, start_chunked_response/3, send_error/4]). + + % /db/_design/foo/show/bar/docid % show converts a json doc to a response of any content-type. % it looks up the doc an then passes it to the query server. % then it sends the response from the query server to the http client. + + handle_doc_show_req(#httpd{ path_parts=[_, _, _, _, ShowName, DocId] }=Req, Db, DDoc) -> @@ -36,6 +40,20 @@ handle_doc_show(Req, Db, DDoc, ShowName, Doc); handle_doc_show_req(#httpd{ + path_parts=[_, _, _, _, ShowName, DocId|Rest] + }=Req, Db, DDoc) -> + + DocParts = [DocId|Rest], + DocId1 = string:join([?b2l(P)|| P <- DocParts], "/"), + + % open the doc + Doc = couch_httpd_db:couch_doc_open(Db, ?l2b(DocId1), nil, [conflicts]), + % we don't handle revs here b/c they are an internal api + % returns 404 if there is no doc with DocId + handle_doc_show(Req, Db, DDoc, ShowName, Doc); + + +handle_doc_show_req(#httpd{ path_parts=[_, _, _, _, ShowName] }=Req, Db, DDoc) -> % with no docid the doc is nil