Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
For a vhost, correctly reflect true requested path
  • Loading branch information
Jason Smith (air) committed Feb 29, 2012
1 parent 24a98d6 commit c14f130
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/couchdb/couch_httpd_external.erl
Expand Up @@ -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) ->
Expand All @@ -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},
Expand Down

0 comments on commit c14f130

Please sign in to comment.