Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

better tests for the vhost globals, fixed a bug

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@949912 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 5731599ef0128fca97444ee34dd2ca71edcaf16a 1 parent c46bbe3
@jchris jchris authored
Showing with 13 additions and 8 deletions.
  1. +8 −2 src/couchdb/couch_httpd.erl
  2. +5 −6 test/etap/160-vhosts.t
View
10 src/couchdb/couch_httpd.erl
@@ -311,8 +311,14 @@ increment_method_stats(Method) ->
% if so, then it will not be rewritten, but will run as a normal couchdb request.
% normally you'd use this for _uuids _utils and a few of the others you want to keep available on vhosts. You can also use it to make databases 'global'.
vhost_global(VhostGlobals, MochiReq) ->
- "/"++Path = MochiReq:get(path),
- [true] == [true||V <- VhostGlobals, V == Path].
+ "/" ++ Path = MochiReq:get(path),
+ Front = case partition(Path) of
+ {"", "", ""} ->
+ "/"; % Special case the root url handler
+ {FirstPart, _, _} ->
+ FirstPart
+ end,
+ [true] == [true||V <- VhostGlobals, V == Front].
% Utilities
View
11 test/etap/160-vhosts.t
@@ -122,11 +122,10 @@ test_vhost_request_with_qs() ->
end.
test_vhost_request_with_global() ->
- Url = server() ++ "_uuids",
- case ibrowse:send_req(Url, [], get, [], [{host_header, "example.com"}]) of
- {ok, _, _, Body} ->
- {JsonProps} = couch_util:json_decode(Body),
- HasUuids = proplists:is_defined(<<"uuids">>, JsonProps),
- etap:is(HasUuids, true, "should return _uuids");
+ Url2 = server() ++ "_utils/index.html",
+ case ibrowse:send_req(Url2, [], get, [], [{host_header, "example.com"}]) of
+ {ok, _, _, Body2} ->
+ "<!DOCTYPE" ++ _Foo = Body2,
+ etap:is(true, true, "should serve /_utils even inside vhosts");
_Else -> false
end.
Please sign in to comment.
Something went wrong with that request. Please try again.