diff options
author | John Christopher Anderson <jchris@apache.org> | 2009-01-30 01:40:38 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2009-01-30 01:40:38 +0000 |
commit | bbd217f334475cd83eaaf24cda71100d4db0efb0 (patch) | |
tree | 8cae9e099ee04f887b8dd722ee07a987363d524b /src | |
parent | dccb6fdd5f8f3fa7c9be6e4cca19586aa91d07a4 (diff) |
POST to create docs returns a Location header. fixes COUCHDB-8
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@739133 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/couchdb/couch_httpd_db.erl | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 2cb4c403..3a8abaf3 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -18,7 +18,7 @@ -import(couch_httpd, [send_json/2,send_json/3,send_json/4,send_method_not_allowed/2, start_json_response/2,send_chunk/2,end_json_response/1, - start_chunked_response/3]). + start_chunked_response/3, absolute_uri/2]). -record(doc_query_args, { options = [], @@ -76,11 +76,13 @@ db_req(#httpd{method='GET',path_parts=[_DbName]}=Req, Db) -> {ok, DbInfo} = couch_db:get_db_info(Db), send_json(Req, {DbInfo}); -db_req(#httpd{method='POST',path_parts=[_DbName]}=Req, Db) -> +db_req(#httpd{method='POST',path_parts=[DbName]}=Req, Db) -> Doc = couch_doc:from_json_obj(couch_httpd:json_body(Req)), DocId = couch_util:new_uuid(), {ok, NewRev} = couch_db:update_doc(Db, Doc#doc{id=DocId, revs=[]}, []), - send_json(Req, 201, {[ + DocUrl = absolute_uri(Req, + binary_to_list(<<"/",DbName/binary,"/",DocId/binary>>)), + send_json(Req, 201, [{"Location", DocUrl}], {[ {ok, true}, {id, DocId}, {rev, NewRev} |