couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan Lehnardt (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COUCHDB-1103) Make vhost definitions not order-dependent, remove variable matching
Date Wed, 20 Apr 2011 19:11:05 GMT

    [ https://issues.apache.org/jira/browse/COUCHDB-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13022309#comment-13022309
] 

Jan Lehnardt commented on COUCHDB-1103:
---------------------------------------

@Benoit, in line
+    DefaultPort = mochiweb_socket_server:get(couch_httpd, port),
did you mean s/mochiweb_socket_server/couch_config/?

If yes, here's a patch against 1.1.x that passes all etap tests for me reliably.

diff --git a/src/couchdb/couch_httpd_vhost.erl b/src/couchdb/couch_httpd_vhost.erl
index 3dba291..b64996a 100644
--- a/src/couchdb/couch_httpd_vhost.erl
+++ b/src/couchdb/couch_httpd_vhost.erl
@@ -329,10 +329,10 @@ 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
@@ -350,15 +350,16 @@ parse_vhost(Vhost) ->
             
 
 split_host_port(HostAsString) ->
+    DefaultPort = couch_config:get(couch_httpd, port),
     case string:rchr(HostAsString, $:) of
         0 ->
-            {split_host(HostAsString), 80};
+            {split_host(HostAsString), DefaultPort};
         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), DefaultPort};
                 Port ->
                     {split_host(HostPart), Port}
             end



> Make vhost definitions not order-dependent, remove variable matching
> --------------------------------------------------------------------
>
>                 Key: COUCHDB-1103
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1103
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>    Affects Versions: 1.1, 1.2
>            Reporter: Jan Lehnardt
>            Assignee: Benoit Chesneau
>            Priority: Critical
>             Fix For: 1.1
>
>         Attachments: 0001-fix-COUCHDB-1103.-Order-results-and-make-sure-we-use.patch
>
>
> As per http://mail-archives.apache.org/mod_mbox/couchdb-dev/201103.mbox/%3cAANLkTin6zRiiFtKZoFa60DRVyOcF1dXzMYtNdKuX=ZRw@mail.gmail.com%3e
> Recording it here to not lose track.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message