mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Update Ranch to 1.6.1
This commit is contained in:
parent
3bda790901
commit
06a3a93de0
3 changed files with 13 additions and 12 deletions
2
Makefile
2
Makefile
|
@ -16,7 +16,7 @@ LOCAL_DEPS = crypto
|
||||||
|
|
||||||
DEPS = cowlib ranch
|
DEPS = cowlib ranch
|
||||||
dep_cowlib = git https://github.com/ninenines/cowlib master
|
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
|
DOC_DEPS = asciideck
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{deps, [
|
{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]}.
|
{erl_opts, [debug_info,warn_export_vars,warn_shadow_vars,warn_obsolete_guard,warn_missing_spec,warn_untyped_record]}.
|
||||||
|
|
|
@ -41,29 +41,30 @@
|
||||||
-type http_version() :: 'HTTP/2' | 'HTTP/1.1' | 'HTTP/1.0'.
|
-type http_version() :: 'HTTP/2' | 'HTTP/1.1' | 'HTTP/1.0'.
|
||||||
-export_type([http_version/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()}.
|
-> {ok, pid()} | {error, any()}.
|
||||||
start_clear(Ref, TransOpts0, ProtoOpts0) ->
|
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},
|
ProtoOpts = ProtoOpts0#{connection_type => ConnectionType},
|
||||||
ranch:start_listener(Ref, ranch_tcp, TransOpts, cowboy_clear, ProtoOpts).
|
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()}.
|
-> {ok, pid()} | {error, any()}.
|
||||||
start_tls(Ref, TransOpts0, ProtoOpts0) ->
|
start_tls(Ref, TransOpts0, ProtoOpts0) ->
|
||||||
{TransOpts1, ConnectionType} = ensure_connection_type(TransOpts0),
|
TransOpts1 = [
|
||||||
TransOpts = [
|
|
||||||
{next_protocols_advertised, [<<"h2">>, <<"http/1.1">>]},
|
{next_protocols_advertised, [<<"h2">>, <<"http/1.1">>]},
|
||||||
{alpn_preferred_protocols, [<<"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},
|
ProtoOpts = ProtoOpts0#{connection_type => ConnectionType},
|
||||||
ranch:start_listener(Ref, ranch_ssl, TransOpts, cowboy_tls, ProtoOpts).
|
ranch:start_listener(Ref, ranch_ssl, TransOpts, cowboy_tls, ProtoOpts).
|
||||||
|
|
||||||
|
ensure_connection_type(TransOpts=#{connection_type := ConnectionType}) ->
|
||||||
|
{TransOpts, ConnectionType};
|
||||||
ensure_connection_type(TransOpts) ->
|
ensure_connection_type(TransOpts) ->
|
||||||
case proplists:get_value(connection_type, TransOpts) of
|
{TransOpts#{connection_type => supervisor}, supervisor}.
|
||||||
undefined -> {[{connection_type, supervisor}|TransOpts], supervisor};
|
|
||||||
ConnectionType -> {TransOpts, ConnectionType}
|
|
||||||
end.
|
|
||||||
|
|
||||||
-spec stop_listener(ranch:ref()) -> ok | {error, not_found}.
|
-spec stop_listener(ranch:ref()) -> ok | {error, not_found}.
|
||||||
stop_listener(Ref) ->
|
stop_listener(Ref) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue