aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--rebar.config2
-rw-r--r--src/cowboy.erl21
3 files changed, 13 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 6c829c7..095b81c 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ LOCAL_DEPS = crypto
DEPS = cowlib ranch
dep_cowlib = git https://github.com/ninenines/cowlib master
-dep_ranch = git https://github.com/ninenines/ranch 1.5.0
+dep_ranch = git https://github.com/ninenines/ranch 1.6.1
DOC_DEPS = asciideck
diff --git a/rebar.config b/rebar.config
index 46d09a7..ae410cf 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,4 +1,4 @@
{deps, [
-{cowlib,".*",{git,"https://github.com/ninenines/cowlib","master"}},{ranch,".*",{git,"https://github.com/ninenines/ranch","1.5.0"}}
+{cowlib,".*",{git,"https://github.com/ninenines/cowlib","master"}},{ranch,".*",{git,"https://github.com/ninenines/ranch","1.6.1"}}
]}.
{erl_opts, [debug_info,warn_export_vars,warn_shadow_vars,warn_obsolete_guard,warn_missing_spec,warn_untyped_record]}.
diff --git a/src/cowboy.erl b/src/cowboy.erl
index 0230f07..ffea69a 100644
--- a/src/cowboy.erl
+++ b/src/cowboy.erl
@@ -41,29 +41,30 @@
-type http_version() :: 'HTTP/2' | 'HTTP/1.1' | 'HTTP/1.0'.
-export_type([http_version/0]).
--spec start_clear(ranch:ref(), ranch_tcp:opts(), opts())
+-spec start_clear(ranch:ref(), ranch:opts(), opts())
-> {ok, pid()} | {error, any()}.
start_clear(Ref, TransOpts0, ProtoOpts0) ->
- {TransOpts, ConnectionType} = ensure_connection_type(TransOpts0),
+ TransOpts1 = ranch:normalize_opts(TransOpts0),
+ {TransOpts, ConnectionType} = ensure_connection_type(TransOpts1),
ProtoOpts = ProtoOpts0#{connection_type => ConnectionType},
ranch:start_listener(Ref, ranch_tcp, TransOpts, cowboy_clear, ProtoOpts).
--spec start_tls(ranch:ref(), ranch_ssl:opts(), opts())
+-spec start_tls(ranch:ref(), ranch:opts(), opts())
-> {ok, pid()} | {error, any()}.
start_tls(Ref, TransOpts0, ProtoOpts0) ->
- {TransOpts1, ConnectionType} = ensure_connection_type(TransOpts0),
- TransOpts = [
+ TransOpts1 = [
{next_protocols_advertised, [<<"h2">>, <<"http/1.1">>]},
{alpn_preferred_protocols, [<<"h2">>, <<"http/1.1">>]}
- |TransOpts1],
+ |TransOpts0],
+ TransOpts2 = ranch:normalize_opts(TransOpts1),
+ {TransOpts, ConnectionType} = ensure_connection_type(TransOpts2),
ProtoOpts = ProtoOpts0#{connection_type => ConnectionType},
ranch:start_listener(Ref, ranch_ssl, TransOpts, cowboy_tls, ProtoOpts).
+ensure_connection_type(TransOpts=#{connection_type := ConnectionType}) ->
+ {TransOpts, ConnectionType};
ensure_connection_type(TransOpts) ->
- case proplists:get_value(connection_type, TransOpts) of
- undefined -> {[{connection_type, supervisor}|TransOpts], supervisor};
- ConnectionType -> {TransOpts, ConnectionType}
- end.
+ {TransOpts#{connection_type => supervisor}, supervisor}.
-spec stop_listener(ranch:ref()) -> ok | {error, not_found}.
stop_listener(Ref) ->