You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2010/02/19 20:07:52 UTC

svn commit: r911938 - /couchdb/trunk/src/couchdb/couch_httpd.erl

Author: jan
Date: Fri Feb 19 19:07:52 2010
New Revision: 911938

URL: http://svn.apache.org/viewvc?rev=911938&view=rev
Log:
use process state instead of config lookup to match vhosts

Modified:
    couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=911938&r1=911937&r2=911938&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Fri Feb 19 19:07:52 2010
@@ -13,7 +13,7 @@
 -module(couch_httpd).
 -include("couch_db.hrl").
 
--export([start_link/0, stop/0, handle_request/5]).
+-export([start_link/0, stop/0, handle_request/6]).
 
 -export([header_value/2,header_value/3,qs_value/2,qs_value/3,qs/1,path/1,absolute_uri/2,body_length/1]).
 -export([verify_is_server_admin/1,unquote/1,quote/1,recv/2,recv_chunked/4,error_info/1]).
@@ -35,6 +35,7 @@
 
     BindAddress = couch_config:get("httpd", "bind_address", any),
     Port = couch_config:get("httpd", "port", "5984"),
+    VirtualHosts = couch_config:get("vhosts"),
 
     DefaultSpec = "{couch_httpd_db, handle_request}",
     DefaultFun = make_arity_1_fun(
@@ -61,7 +62,8 @@
     DesignUrlHandlers = dict:from_list(DesignUrlHandlersList),
     Loop = fun(Req)->
         apply(?MODULE, handle_request, [
-            Req, DefaultFun, UrlHandlers, DbUrlHandlers, DesignUrlHandlers
+            Req, DefaultFun, UrlHandlers, DbUrlHandlers, DesignUrlHandlers,
+                VirtualHosts
         ])
     end,
 
@@ -89,6 +91,8 @@
         ("httpd_global_handlers", _) ->
             ?MODULE:stop();
         ("httpd_db_handlers", _) ->
+            ?MODULE:stop();
+        ("vhosts", _) ->
             ?MODULE:stop()
         end, Pid),
 
@@ -149,14 +153,14 @@
         UrlHandlers, DbUrlHandlers, DesignUrlHandlers).
 
 handle_request(MochiReq, DefaultFun,
-    UrlHandlers, DbUrlHandlers, DesignUrlHandlers) ->
+    UrlHandlers, DbUrlHandlers, DesignUrlHandlers, VirtualHosts) ->
 
     % grab Host from Req
     Vhost = MochiReq:get_header_value("Host"),
 
     % find Vhost in config
-    case couch_config:get("vhosts", Vhost, false) of
-        false -> % business as usual
+    case proplists:get_value(Vhost, VirtualHosts) of
+        undefined -> % business as usual
             handle_request_int(MochiReq, DefaultFun,
                     UrlHandlers, DbUrlHandlers, DesignUrlHandlers);
         VhostTarget ->