mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 20:50:24 +00:00
Update Ranch to 0.8.0
This commit is contained in:
parent
ce1d8862c0
commit
2b56bb498f
6 changed files with 13 additions and 13 deletions
|
@ -84,9 +84,9 @@
|
|||
%% API.
|
||||
|
||||
%% @doc Start an HTTP protocol process.
|
||||
-spec start_link(pid(), inet:socket(), module(), any()) -> {ok, pid()}.
|
||||
start_link(ListenerPid, Socket, Transport, Opts) ->
|
||||
Pid = spawn_link(?MODULE, init, [ListenerPid, Socket, Transport, Opts]),
|
||||
-spec start_link(any(), inet:socket(), module(), any()) -> {ok, pid()}.
|
||||
start_link(Ref, Socket, Transport, Opts) ->
|
||||
Pid = spawn_link(?MODULE, init, [Ref, Socket, Transport, Opts]),
|
||||
{ok, Pid}.
|
||||
|
||||
%% Internal.
|
||||
|
@ -100,8 +100,8 @@ get_value(Key, Opts, Default) ->
|
|||
end.
|
||||
|
||||
%% @private
|
||||
-spec init(pid(), inet:socket(), module(), any()) -> ok.
|
||||
init(ListenerPid, Socket, Transport, Opts) ->
|
||||
-spec init(any(), inet:socket(), module(), any()) -> ok.
|
||||
init(Ref, Socket, Transport, Opts) ->
|
||||
Compress = get_value(compress, Opts, false),
|
||||
MaxEmptyLines = get_value(max_empty_lines, Opts, 5),
|
||||
MaxHeaderNameLength = get_value(max_header_name_length, Opts, 64),
|
||||
|
@ -110,11 +110,11 @@ init(ListenerPid, Socket, Transport, Opts) ->
|
|||
MaxKeepalive = get_value(max_keepalive, Opts, 100),
|
||||
MaxRequestLineLength = get_value(max_request_line_length, Opts, 4096),
|
||||
Middlewares = get_value(middlewares, Opts, [cowboy_router, cowboy_handler]),
|
||||
Env = [{listener, ListenerPid}|get_value(env, Opts, [])],
|
||||
Env = [{listener, Ref}|get_value(env, Opts, [])],
|
||||
OnRequest = get_value(onrequest, Opts, undefined),
|
||||
OnResponse = get_value(onresponse, Opts, undefined),
|
||||
Timeout = get_value(timeout, Opts, 5000),
|
||||
ok = ranch:accept_ack(ListenerPid),
|
||||
ok = ranch:accept_ack(Ref),
|
||||
wait_request(<<>>, #state{socket=Socket, transport=Transport,
|
||||
middlewares=Middlewares, compress=Compress, env=Env,
|
||||
max_empty_lines=MaxEmptyLines, max_keepalive=MaxKeepalive,
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
| {suspend, module(), atom(), [any()]}
|
||||
when Req::cowboy_req:req(), Env::cowboy_middleware:env().
|
||||
upgrade(Req, Env, Handler, HandlerOpts) ->
|
||||
{_, ListenerPid} = lists:keyfind(listener, 1, Env),
|
||||
ranch_listener:remove_connection(ListenerPid),
|
||||
{_, Ref} = lists:keyfind(listener, 1, Env),
|
||||
ranch:remove_connection(Ref),
|
||||
[Socket, Transport] = cowboy_req:get([socket, transport], Req),
|
||||
State = #state{env=Env, socket=Socket, transport=Transport,
|
||||
handler=Handler, handler_opts=HandlerOpts},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue