From 6b53d12b758b8e917a92e9d34eb59aa575d000b7 Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Fri, 27 Mar 2009 00:26:39 +0000 Subject: Location header responses should be absolute URIs, thanks Christopher git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@758942 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_httpd_db.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 78b127b4..07815bda 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -56,7 +56,8 @@ 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, [{"Location", "/" ++ DbName}], {[{ok, true}]}); + DocUrl = absolute_uri(Req, "/" ++ DbName), + send_json(Req, 201, [{"Location", DocUrl}], {[{ok, true}]}); Error -> throw(Error) end. @@ -496,8 +497,9 @@ db_doc_req(#httpd{method='POST'}=Req, Db, DocId) -> ]}); db_doc_req(#httpd{method='PUT'}=Req, Db, DocId) -> + Location = absolute_uri(Req, "/" ++ ?b2l(Db#db.name) ++ "/" ++ ?b2l(DocId)), update_doc(Req, Db, DocId, couch_httpd:json_body(Req), - [{"Location", "/" ++ ?b2l(Db#db.name) ++ "/" ++ ?b2l(DocId)}]); + [{"Location", Location}]); db_doc_req(#httpd{method='COPY'}=Req, Db, SourceDocId) -> SourceRev = -- cgit v1.2.3