couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject couch commit: updated refs/heads/master to 9578fac
Date Sat, 22 Aug 2015 11:11:13 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/master 4c8f4bb19 -> 9578fac8a


Bind both to IPv4 and IPv6 with special "any" value

This also removes need in special wrapper to handle atom as default
for config:get call.

COUCHDB-2783


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/9578fac8
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/9578fac8
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/9578fac8

Branch: refs/heads/master
Commit: 9578fac8a5af8fc06522ac3c9c6e22c683965618
Parents: 4c8f4bb
Author: Alexander Shorin <kxepal@apache.org>
Authored: Fri Aug 21 11:14:28 2015 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Sat Aug 22 14:09:08 2015 +0300

----------------------------------------------------------------------
 src/couch_httpd.erl | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/9578fac8/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index df2993b..720ea0a 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -31,6 +31,7 @@
 -export([accepted_encodings/1,handle_request_int/5,validate_referer/1,validate_ctype/2]).
 -export([http_1_0_keep_alive/2]).
 -export([validate_host/1]).
+-export([validate_bind_address/1]).
 
 -define(HANDLER_NAME_IN_MODULE_POS, 6).
 
@@ -90,8 +91,11 @@ start_link(https) ->
          {ssl_opts, SslOpts}],
     start_link(https, Options).
 start_link(Name, Options) ->
-    BindAddress = with_default(config:get("httpd", "bind_address"), any),
-    validate_bind_address(BindAddress),
+    BindAddress = case config:get("httpd", "bind_address", "any") of
+                      "any" -> any;
+                      Else -> Else
+                  end,
+    ok = validate_bind_address(BindAddress),
     DefaultSpec = "{couch_httpd_db, handle_request}",
     DefaultFun = make_arity_1_fun(
         config:get("httpd", "default_handler", DefaultSpec)
@@ -1116,11 +1120,9 @@ check_for_last(#mp{buffer=Buffer, data_fun=DataFun}=Mp) ->
                 data_fun = DataFun2})
     end.
 
+validate_bind_address(any) -> ok;
 validate_bind_address(Address) ->
     case inet_parse:address(Address) of
         {ok, _} -> ok;
         _ -> throw({error, invalid_bind_address})
     end.
-
-with_default(undefined, Default) -> Default;
-with_default(Value, _) -> Value.


Mime
View raw message