From 5b4e78fac483c5eb277fec4ab7e8c6a62821bf4b Mon Sep 17 00:00:00 2001 From: juhlig Date: Thu, 6 Jun 2019 17:52:34 +0200 Subject: Make Cowboy compatible with upcoming Ranch 2.0 --- src/cowboy_tls.erl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/cowboy_tls.erl') diff --git a/src/cowboy_tls.erl b/src/cowboy_tls.erl index 864a613..c049ecb 100644 --- a/src/cowboy_tls.erl +++ b/src/cowboy_tls.erl @@ -15,17 +15,24 @@ -module(cowboy_tls). -behavior(ranch_protocol). +-export([start_link/3]). -export([start_link/4]). --export([connection_process/5]). +-export([connection_process/4]). +%% Ranch 1. -spec start_link(ranch:ref(), ssl:sslsocket(), module(), cowboy:opts()) -> {ok, pid()}. -start_link(Ref, Socket, Transport, Opts) -> +start_link(Ref, _Socket, Transport, Opts) -> + start_link(Ref, Transport, Opts). + +%% Ranch 2. +-spec start_link(ranch:ref(), module(), cowboy:opts()) -> {ok, pid()}. +start_link(Ref, Transport, Opts) -> Pid = proc_lib:spawn_link(?MODULE, connection_process, - [self(), Ref, Socket, Transport, Opts]), + [self(), Ref, Transport, Opts]), {ok, Pid}. --spec connection_process(pid(), ranch:ref(), ssl:sslsocket(), module(), cowboy:opts()) -> ok. -connection_process(Parent, Ref, Socket, Transport, Opts) -> +-spec connection_process(pid(), ranch:ref(), module(), cowboy:opts()) -> ok. +connection_process(Parent, Ref, Transport, Opts) -> ProxyInfo = case maps:get(proxy_header, Opts, false) of true -> {ok, ProxyInfo0} = ranch:recv_proxy_header(Ref, 1000), -- cgit v1.2.3