You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by jh...@apache.org on 2012/02/29 12:09:58 UTC

[6/9] git commit: For a vhost, correctly reflect true requested path

For a vhost, correctly reflect true requested path


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

Branch: refs/heads/COUCHDB-1416
Commit: c14f130f61b0d6b611e3cce8bb7b2f11e39e99f5
Parents: 24a98d6
Author: Jason Smith (air) <jh...@apache.org>
Authored: Wed Feb 29 03:41:41 2012 +0000
Committer: Jason Smith (air) <jh...@apache.org>
Committed: Wed Feb 29 03:41:41 2012 +0000

----------------------------------------------------------------------
 src/couchdb/couch_httpd_external.erl |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/c14f130f/src/couchdb/couch_httpd_external.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_external.erl b/src/couchdb/couch_httpd_external.erl
index bfe77a3..de9e825 100644
--- a/src/couchdb/couch_httpd_external.erl
+++ b/src/couchdb/couch_httpd_external.erl
@@ -56,7 +56,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,
+               requested_path_parts=RequestedPathParts,
                path_parts=Path,
                req_body=ReqBody
             }, Db, DocId) ->
@@ -79,7 +79,18 @@ json_req_obj(#httpd{mochi_req=Req,
     Headers = Req:get(headers),
     Hlist = mochiweb_headers:to_list(Headers),
     {ok, Info} = couch_db:get_db_info(Db),
-    
+
+    % RequestedPath must match exactly the path originally received.
+    RequestedPath = case mochiweb_headers:get_value("x-couchdb-vhost-fullpath",
+            Headers) of
+        undefined ->
+            RequestedPathParts;
+        FullPath ->
+            {"/" ++ VPath, _Query, _Fragment} =
+                    mochiweb_util:urlsplit_path(FullPath),
+            [ ?l2b(Part) || Part <- string:tokens(VPath, "/") ]
+    end,
+
 % add headers...
     {[{<<"info">>, {Info}},
         {<<"id">>, DocId},