summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2011-04-25 23:46:12 +0000
committerJan Lehnardt <jan@apache.org>2011-04-25 23:46:12 +0000
commit0e0e8d3375cb4b7ebb1edd25ac9302f6e22e2b93 (patch)
treef6cff5dbed0b7eb15ea9e5aa5040d078148d9787 /src
parentb9c5282ea2220e09332c70ad5fbeae4b3be75b76 (diff)
Fix vhosts for https and fix vhost dependence on sorting of
values in the config system which isn't guaranteed. Make vhost test cases more robust. Closes COUCHDB-1103 Source patch by Benoit and tests patch by me. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1096636 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_httpd_vhost.erl15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/couchdb/couch_httpd_vhost.erl b/src/couchdb/couch_httpd_vhost.erl
index 3dba2919..9bfb5951 100644
--- a/src/couchdb/couch_httpd_vhost.erl
+++ b/src/couchdb/couch_httpd_vhost.erl
@@ -301,6 +301,7 @@ make_target([P|Rest], Bindings, Remaining, Acc) ->
%% bind port
bind_port(Port, Port) -> ok;
+bind_port('*', _) -> ok;
bind_port(_,_) -> fail.
%% bind bhost
@@ -329,15 +330,15 @@ bind_path(_, _) ->
%% create vhost list from ini
make_vhosts() ->
- lists:foldl(fun({Vhost, Path}, Acc) ->
- [{parse_vhost(Vhost), split_path(Path)}|Acc]
- end, [], couch_config:get("vhosts")).
-
+ Vhosts = lists:foldl(fun({Vhost, Path}, Acc) ->
+ [{parse_vhost(Vhost), split_path(Path)}|Acc]
+ end, [], couch_config:get("vhosts")),
+ lists:reverse(lists:usort(Vhosts)).
parse_vhost(Vhost) ->
case urlsplit_netloc(Vhost, []) of
{[], Path} ->
- {make_spec("*", []), 80, Path};
+ {make_spec("*", []), '*', Path};
{HostPort, []} ->
{H, P} = split_host_port(HostPort),
H1 = make_spec(H, []),
@@ -352,13 +353,13 @@ parse_vhost(Vhost) ->
split_host_port(HostAsString) ->
case string:rchr(HostAsString, $:) of
0 ->
- {split_host(HostAsString), 80};
+ {split_host(HostAsString), '*'};
N ->
HostPart = string:substr(HostAsString, 1, N-1),
case (catch erlang:list_to_integer(HostAsString, N+1,
length(HostAsString))) of
{'EXIT', _} ->
- {split_host(HostAsString), 80};
+ {split_host(HostAsString), '*'};
Port ->
{split_host(HostPart), Port}
end