From 39a927058a066e7c7c31cb4388371f2c8b639e4b Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Thu, 26 Mar 2009 16:28:21 +0000 Subject: return Location header for newly create databases git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@758723 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/basics.js | 6 ++++++ src/couchdb/couch_httpd_db.erl | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/share/www/script/test/basics.js b/share/www/script/test/basics.js index 217f9aef..ebfe5db2 100644 --- a/share/www/script/test/basics.js +++ b/share/www/script/test/basics.js @@ -28,6 +28,12 @@ couchTests.basics = function(debug) { T(xhr.status == 412); if (debug) debugger; + // creating a new DB should return Location header + xhr = CouchDB.request("DELETE", "/new-db"); + xhr = CouchDB.request("PUT", "/new-db"); + TEquals("/new-db", xhr.getResponseHeader("Location"), + "should return newly created database name in location header"); + // Get the database info, check the db_name T(db.info().db_name == "test_suite_db"); diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 2bfc2940..92ad98c8 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -56,7 +56,7 @@ create_db_req(#httpd{user_ctx=UserCtx}=Req, DbName) -> case couch_server:create(DbName, [{user_ctx, UserCtx}]) of {ok, Db} -> couch_db:close(Db), - send_json(Req, 201, {[{ok, true}]}); + send_json(Req, 201, [{"Location", "/" ++ DbName}], {[{ok, true}]}); Error -> throw(Error) end. -- cgit v1.2.3