You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ii...@apache.org on 2016/03/01 21:01:17 UTC
[44/50] couch-httpd commit: updated refs/heads/split_out_httpd_stack
to e44a372
Pass Stack to couch_httpd_handler:start_link
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/d2b09732
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/tree/d2b09732
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/diff/d2b09732
Branch: refs/heads/split_out_httpd_stack
Commit: d2b097328530bf92641d18cc41e6e6331b744477
Parents: e48282f
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Authored: Fri Feb 26 13:32:00 2016 -0800
Committer: ILYA Khlopotov <ii...@ca.ibm.com>
Committed: Tue Mar 1 08:35:09 2016 -0800
----------------------------------------------------------------------
src/couch_httpd.erl | 18 ++++++++++++++++++
src/couch_httpd_handler.erl | 27 +++++++++++----------------
2 files changed, 29 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/d2b09732/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index 929a9b7..7687453 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -15,6 +15,12 @@
-include_lib("couch_httpd/include/couch_httpd.hrl").
-export([
+ start_link/0,
+ start_link/1,
+ start_link/2
+]).
+
+-export([
start_response_length/4,
start_response/3,
start_chunked_response/3,
@@ -121,6 +127,18 @@
resp=nil
}).
+%% For backward compatibility
+start_link() ->
+ start_link(http).
+
+start_link(Protocol) when is_atom(Protocol) -> %% For backward compatibility
+ couch_http_stack:start_link(Protocol);
+start_link(Stack) ->
+ start_link(Stack, Stack:protocol()).
+
+start_link(Stack, ProtocolOrOptions) ->
+ couch_httpd_handler:start_link(Stack, ProtocolOrOptions).
+
start_response_length(#httpd{}=Req, Code, Headers, Length) ->
Resp = handle_response(Req, Code, Headers, Length, start_response_length),
maybe_abort_head_request(Req, Resp).
http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/d2b09732/src/couch_httpd_handler.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd_handler.erl b/src/couch_httpd_handler.erl
index 245dd55..5e9543a 100644
--- a/src/couch_httpd_handler.erl
+++ b/src/couch_httpd_handler.erl
@@ -15,10 +15,8 @@
-include_lib("couch_httpd/include/couch_httpd.hrl").
-export([
- start_link/0,
- start_link/1,
start_link/2,
- stop/0
+ stop/1
]).
-export([
@@ -40,22 +38,19 @@
resp=nil
}).
-start_link() ->
- start_link(http).
-start_link(http) ->
- Port = config:get("chttpd", "port", "5984"),
- start_link(?MODULE, [{port, Port}]);
+start_link(Stack, http) ->
+ start_link(Stack, [{port, Stack:port()}]);
-start_link(https) ->
+start_link(Stack, https) ->
Port = config:get("ssl", "port", "6984"),
Options =
[{port, Port},
{ssl, true},
{ssl_opts, ssl_options()}],
- start_link(https, Options).
+ start_link(Stack, Options);
-start_link(Name, Options) ->
+start_link(Stack, Options) ->
IP = case config:get("chttpd", "bind_address", "any") of
"any" -> any;
Else -> Else
@@ -63,8 +58,8 @@ start_link(Name, Options) ->
ok = couch_httpd:validate_bind_address(IP),
Options1 = Options ++ [
- {loop, fun ?MODULE:handle_request/1},
- {name, Name},
+ {loop, fun(Req) -> ?MODULE:handle_request(Stack, Req) end},
+ {name, Stack:name()},
{ip, IP}
],
ServerOptsCfg = config:get("chttpd", "server_options", "[]"),
@@ -78,9 +73,9 @@ start_link(Name, Options) ->
{error, Reason}
end.
-stop() ->
- catch mochiweb_http:stop(https),
- mochiweb_http:stop(?MODULE).
+stop(Name) ->
+ catch mochiweb_http:stop(Name),
+ ok.
handle_request(Stack, MochiReq0) ->
erlang:put(?REWRITE_COUNT, 0),