You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2015/06/02 21:31:24 UTC

[34/41] chttpd commit: updated refs/heads/2080-port-cors to e2c2bd7

json_req_obj compartible with backdoor interface

Clustered call would return additional fields:

- requested_path
- raw_path
- secObj

COUCHDB-2656


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/0b5e15e0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/0b5e15e0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/0b5e15e0

Branch: refs/heads/2080-port-cors
Commit: 0b5e15e0ff9cd5ec13f5a332b0c3f1f2951ccfac
Parents: 1a15afc
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Authored: Thu Apr 16 07:50:58 2015 -0700
Committer: ILYA Khlopotov <ii...@ca.ibm.com>
Committed: Thu Apr 16 07:50:58 2015 -0700

----------------------------------------------------------------------
 src/chttpd_external.erl | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/0b5e15e0/src/chttpd_external.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_external.erl b/src/chttpd_external.erl
index 38932d1..6986a04 100644
--- a/src/chttpd_external.erl
+++ b/src/chttpd_external.erl
@@ -57,6 +57,7 @@ process_external_req(HttpReq, Db, Name) ->
 json_req_obj(Req, Db) -> json_req_obj(Req, Db, null).
 json_req_obj(#httpd{mochi_req=Req,
                method=Method,
+               requested_path_parts=RequestedPath,
                path_parts=Path,
                req_body=ReqBody
             }, Db, DocId) ->
@@ -75,21 +76,29 @@ json_req_obj(#httpd{mochi_req=Req,
     end,
     Headers = Req:get(headers),
     Hlist = mochiweb_headers:to_list(Headers),
-    {ok, Info} = fabric:get_db_info(Db),
+    {ok, Info} = get_db_info(Db),
 
     % add headers...
     {[{<<"info">>, {Info}},
         {<<"uuid">>, couch_uuids:new()},
         {<<"id">>, DocId},
         {<<"method">>, Method},
+        {<<"requested_path">>, RequestedPath},
         {<<"path">>, Path},
+        {<<"raw_path">>, ?l2b(Req:get(raw_path))},
         {<<"query">>, json_query_keys(to_json_terms(Req:parse_qs()))},
         {<<"headers">>, to_json_terms(Hlist)},
         {<<"body">>, Body},
         {<<"peer">>, ?l2b(Req:get(peer))},
         {<<"form">>, to_json_terms(ParsedForm)},
         {<<"cookie">>, to_json_terms(Req:parse_cookie())},
-        {<<"userCtx">>, couch_util:json_user_ctx(Db)}]}.
+        {<<"userCtx">>, couch_util:json_user_ctx(Db)},
+        {<<"secObj">>, couch_db:get_security(Db)}]}.
+
+get_db_info(#db{main_pid = nil} = Db) ->
+    fabric:get_db_info(Db);
+get_db_info(#db{} = Db) ->
+    couch_db:get_db_info(Db).
 
 to_json_terms(Data) ->
     to_json_terms(Data, []).