Bring validate_bind_address/1 from original
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/commit/a8e03e2f Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/tree/a8e03e2f Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/diff/a8e03e2f Branch: refs/heads/split_out_httpd_stack Commit: a8e03e2f7c614bb171ad55149659035dcb91b28e Parents: ebf1b53 Author: ILYA Khlopotov <iil...@ca.ibm.com> Authored: Fri Feb 26 09:55:27 2016 -0800 Committer: ILYA Khlopotov <iil...@ca.ibm.com> Committed: Tue Mar 1 08:35:08 2016 -0800 ---------------------------------------------------------------------- src/couch_httpd.erl | 10 +++++++++- src/couch_httpd_original.erl | 10 ++-------- 2 files changed, 11 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/a8e03e2f/src/couch_httpd.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl index 4f78bac..53b98e3 100644 --- a/src/couch_httpd.erl +++ b/src/couch_httpd.erl @@ -89,7 +89,8 @@ -export([ validate_ctype/2, validate_referer/1, - validate_host/1 + validate_host/1, + validate_bind_address/1 ]). -export([ @@ -459,6 +460,13 @@ validate_host(#httpd{} = Req) -> ok end. +validate_bind_address(any) -> ok; +validate_bind_address(Address) -> + case inet_parse:address(Address) of + {ok, _} -> ok; + _ -> throw({error, invalid_bind_address}) + end. + host_for_request(#httpd{mochi_req = MochiReq}) -> XHost = config:get("httpd", "x_forwarded_host", "X-Forwarded-Host"), case MochiReq:get_header_value(XHost) of http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/a8e03e2f/src/couch_httpd_original.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd_original.erl b/src/couch_httpd_original.erl index 8fa926b..abbce0e 100644 --- a/src/couch_httpd_original.erl +++ b/src/couch_httpd_original.erl @@ -23,7 +23,6 @@ -export([send_error/2,send_error/4, send_chunked_error/2]). -export([handle_request_int/5]). --export([validate_bind_address/1]). -import(couch_httpd, [ server_header/0, @@ -72,7 +71,8 @@ start_chunked_response/3, validate_host/1, accepted_encodings/1, - validate_referer/1 + validate_referer/1, + validate_bind_address/1 ]). -define(HANDLER_NAME_IN_MODULE_POS, 6). @@ -558,12 +558,6 @@ send_chunked_error(Resp, Error) -> -validate_bind_address(any) -> ok; -validate_bind_address(Address) -> - case inet_parse:address(Address) of - {ok, _} -> ok; - _ -> throw({error, invalid_bind_address}) - end. %%%%%%%% module tests below %%%%%%%%