0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

Remove NumAcceptors argument from start_clear/tls

They are now cowboy:start_clear/3 and cowboy:start_tls/3.
The NumAcceptors argument can be specified via the
num_acceptor transport option. Ranch has been updated
to 1.4.0 to that effect.
This commit is contained in:
Loïc Hoguin 2017-06-07 15:15:54 +02:00
parent 767da623f1
commit 6f7b59886e
No known key found for this signature in database
GPG key ID: 71366FF21851DF03
30 changed files with 45 additions and 83 deletions

View file

@ -21,7 +21,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.3.0 dep_ranch = git https://github.com/ninenines/ranch 1.4.0
DOC_DEPS = asciideck DOC_DEPS = asciideck

View file

@ -99,7 +99,7 @@ start(_Type, _Args) ->
Dispatch = cowboy_router:compile([ Dispatch = cowboy_router:compile([
{'_', [{"/", hello_handler, []}]} {'_', [{"/", hello_handler, []}]}
]), ]),
{ok, _} = cowboy:start_clear(my_http_listener, 100, {ok, _} = cowboy:start_clear(my_http_listener,
[{port, 8080}], [{port, 8080}],
#{env => #{dispatch => Dispatch}} #{env => #{dispatch => Dispatch}}
), ),

View file

@ -31,7 +31,7 @@ start(_Type, _Args) ->
Dispatch = cowboy_router:compile([ Dispatch = cowboy_router:compile([
{'_', [{"/", hello_handler, []}]} {'_', [{"/", hello_handler, []}]}
]), ]),
{ok, _} = cowboy:start_clear(my_http_listener, 100, {ok, _} = cowboy:start_clear(my_http_listener,
[{port, 8080}], [{port, 8080}],
#{env => #{dispatch => Dispatch}} #{env => #{dispatch => Dispatch}}
), ),
@ -75,7 +75,7 @@ start(_Type, _Args) ->
Dispatch = cowboy_router:compile([ Dispatch = cowboy_router:compile([
{'_', [{"/", hello_handler, []}]} {'_', [{"/", hello_handler, []}]}
]), ]),
{ok, _} = cowboy:start_tls(my_http_listener, 100, {ok, _} = cowboy:start_tls(my_http_listener,
[ [
{port, 8443}, {port, 8443},
{certfile, "/path/to/certfile"}, {certfile, "/path/to/certfile"},

View file

@ -203,7 +203,7 @@ Dispatch = cowboy_router:compile([
{'_', [{'_', my_handler, #{}}]} {'_', [{'_', my_handler, #{}}]}
]), ]),
%% Name, NbAcceptors, TransOpts, ProtoOpts %% Name, NbAcceptors, TransOpts, ProtoOpts
cowboy:start_clear(my_http_listener, 100, cowboy:start_clear(my_http_listener,
[{port, 8080}], [{port, 8080}],
#{env => #{dispatch => Dispatch}} #{env => #{dispatch => Dispatch}}
). ).

View file

@ -9,7 +9,6 @@ cowboy:start_clear - Listen for connections using plain TCP
[source,erlang] [source,erlang]
---- ----
start_clear(Name :: ranch:ref(), start_clear(Name :: ranch:ref(),
NumAcceptors :: non_neg_integer(),
TransportOpts :: ranch_tcp:opts(), TransportOpts :: ranch_tcp:opts(),
ProtocolOpts :: opts()) ProtocolOpts :: opts())
-> {ok, ListenerPid :: pid()} -> {ok, ListenerPid :: pid()}
@ -34,22 +33,6 @@ updating the routes defined.
It can be any Erlang term. An atom is generally good enough, It can be any Erlang term. An atom is generally good enough,
for example `api`, `my_app_clear` or `my_app_tls`. for example `api`, `my_app_clear` or `my_app_tls`.
NumAcceptors::
The number of acceptors is the number of processes that
will accept connections. Tweak this value to improve the
accept rate for incoming connections.
+
The ideal value is between 10 and 100 on most systems.
Larger values may have the opposite effect and reduce the
accept rate. It's generally safe to start with a value of
100 (or 10 on low memory systems). Then, when accept rates
become a concern, measure the performance and update the
value accordingly.
+
This value is unrelated to the maximum number of concurrent
connections.
TransportOpts:: TransportOpts::
The transport options are where the TCP options, including The transport options are where the TCP options, including
@ -102,7 +85,7 @@ Dispatch = cowboy_router:compile([
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(example, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(example, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}). }).
---- ----
@ -112,7 +95,7 @@ Dispatch = cowboy_router:compile([
---- ----
Name = example, Name = example,
{ok, _} = cowboy:start_clear(Name, 100, [], #{ {ok, _} = cowboy:start_clear(Name, [], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),

View file

@ -9,7 +9,6 @@ cowboy:start_tls - Listen for connections using TLS
[source,erlang] [source,erlang]
---- ----
start_tls(Name :: ranch:ref(), start_tls(Name :: ranch:ref(),
NumAcceptors :: non_neg_integer(),
TransportOpts :: ranch_ssl:opts(), TransportOpts :: ranch_ssl:opts(),
ProtocolOpts :: opts()) ProtocolOpts :: opts())
-> {ok, ListenerPid :: pid()} -> {ok, ListenerPid :: pid()}
@ -33,22 +32,6 @@ updating the routes defined.
It can be any Erlang term. An atom is generally good enough, It can be any Erlang term. An atom is generally good enough,
for example `api`, `my_app_clear` or `my_app_tls`. for example `api`, `my_app_clear` or `my_app_tls`.
NumAcceptors::
The number of acceptors is the number of processes that
will accept connections. Tweak this value to improve the
accept rate for incoming connections.
+
The ideal value is between 10 and 100 on most systems.
Larger values may have the opposite effect and reduce the
accept rate. It's generally safe to start with a value of
100 (or 10 on low memory systems). Then, when accept rates
become a concern, measure the performance and update the
value accordingly.
+
This value is unrelated to the maximum number of concurrent
connections.
TransportOpts:: TransportOpts::
The transport options are where the TCP options, including The transport options are where the TCP options, including
@ -102,7 +85,7 @@ Dispatch = cowboy_router:compile([
]} ]}
]), ]),
{ok, _} = cowboy:start_tls(example, 100, [ {ok, _} = cowboy:start_tls(example, [
{port, 8443}, {port, 8443},
{cert, "path/to/cert.pem"} {cert, "path/to/cert.pem"}
], #{ ], #{
@ -115,7 +98,7 @@ Dispatch = cowboy_router:compile([
---- ----
Name = example, Name = example,
{ok, _} = cowboy:start_tls(Name, 100, [ {ok, _} = cowboy:start_tls(Name, [
{cert, "path/to/cert.pem"} {cert, "path/to/cert.pem"}
], #{ ], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}

View file

@ -38,7 +38,7 @@ opts() :: #{
Configuration for the HTTP/1.1 protocol. Configuration for the HTTP/1.1 protocol.
This configuration is passed to Cowboy when starting listeners This configuration is passed to Cowboy when starting listeners
using `cowboy:start_clear/4` or `cowboy:start_tls/4` functions. using `cowboy:start_clear/3` or `cowboy:start_tls/3` functions.
It can be updated without restarting listeners using the It can be updated without restarting listeners using the
Ranch functions `ranch:get_protocol_options/1` and Ranch functions `ranch:get_protocol_options/1` and

View file

@ -30,7 +30,7 @@ opts() :: #{
Configuration for the HTTP/2 protocol. Configuration for the HTTP/2 protocol.
This configuration is passed to Cowboy when starting listeners This configuration is passed to Cowboy when starting listeners
using `cowboy:start_clear/4` or `cowboy:start_tls/4` functions. using `cowboy:start_clear/3` or `cowboy:start_tls/3` functions.
It can be updated without restarting listeners using the It can be updated without restarting listeners using the
Ranch functions `ranch:get_protocol_options/1` and Ranch functions `ranch:get_protocol_options/1` and

View file

@ -43,7 +43,7 @@ Dispatch = cowboy_router:compile([
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(example, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(example, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}). }).
---- ----

View file

@ -16,7 +16,7 @@ start(_Type, _Args) ->
{"/", toppage_handler, []} {"/", toppage_handler, []}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),
chunked_hello_world_sup:start_link(). chunked_hello_world_sup:start_link().

View file

@ -16,7 +16,7 @@ start(_Type, _Args) ->
{"/", toppage_handler, []} {"/", toppage_handler, []}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch}, env => #{dispatch => Dispatch},
stream_handlers => [cowboy_compress_h, cowboy_stream_h] stream_handlers => [cowboy_compress_h, cowboy_stream_h]
}), }),

View file

@ -16,7 +16,7 @@ start(_Type, _Args) ->
{'_', toppage_handler, []} {'_', toppage_handler, []}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),
cookie_sup:start_link(). cookie_sup:start_link().

View file

@ -16,7 +16,7 @@ start(_Type, _Args) ->
{"/", toppage_handler, []} {"/", toppage_handler, []}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),
echo_get_sup:start_link(). echo_get_sup:start_link().

View file

@ -16,7 +16,7 @@ start(_Type, _Args) ->
{"/", toppage_handler, []} {"/", toppage_handler, []}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),
echo_post_sup:start_link(). echo_post_sup:start_link().

View file

@ -17,7 +17,7 @@ start(_Type, _Args) ->
{"/", cowboy_static, {priv_file, eventsource, "index.html"}} {"/", cowboy_static, {priv_file, eventsource, "index.html"}}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),
eventsource_sup:start_link(). eventsource_sup:start_link().

View file

@ -19,7 +19,7 @@ start(_Type, _Args) ->
]}} ]}}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch}, env => #{dispatch => Dispatch},
middlewares => [cowboy_router, directory_lister, cowboy_handler] middlewares => [cowboy_router, directory_lister, cowboy_handler]
}), }),

View file

@ -16,7 +16,7 @@ start(_Type, _Args) ->
{"/", toppage_handler, []} {"/", toppage_handler, []}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),
hello_world_sup:start_link(). hello_world_sup:start_link().

View file

@ -16,7 +16,7 @@ start(_Type, _Args) ->
{"/[...]", cowboy_static, {priv_dir, markdown_middleware, ""}} {"/[...]", cowboy_static, {priv_dir, markdown_middleware, ""}}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch}, env => #{dispatch => Dispatch},
middlewares => [cowboy_router, markdown_converter, cowboy_handler] middlewares => [cowboy_router, markdown_converter, cowboy_handler]
}), }),

View file

@ -16,7 +16,7 @@ start(_Type, _Args) ->
{"/", toppage_handler, []} {"/", toppage_handler, []}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),
rest_basic_auth_sup:start_link(). rest_basic_auth_sup:start_link().

View file

@ -16,7 +16,7 @@ start(_Type, _Args) ->
{"/", toppage_handler, []} {"/", toppage_handler, []}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),
rest_hello_world_sup:start_link(). rest_hello_world_sup:start_link().

View file

@ -16,7 +16,7 @@ start(_Type, _Args) ->
{"/[:paste_id]", toppage_handler, []} {"/[:paste_id]", toppage_handler, []}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),
rest_pastebin_sup:start_link(). rest_pastebin_sup:start_link().

View file

@ -17,7 +17,7 @@ start(_Type, _Args) ->
]} ]}
]), ]),
PrivDir = code:priv_dir(ssl_hello_world), PrivDir = code:priv_dir(ssl_hello_world),
{ok, _} = cowboy:start_tls(https, 100, [ {ok, _} = cowboy:start_tls(https, [
{port, 8443}, {port, 8443},
{cacertfile, PrivDir ++ "/ssl/cowboy-ca.crt"}, {cacertfile, PrivDir ++ "/ssl/cowboy-ca.crt"},
{certfile, PrivDir ++ "/ssl/server.crt"}, {certfile, PrivDir ++ "/ssl/server.crt"},

View file

@ -16,7 +16,7 @@ start(_Type, _Args) ->
{"/upload", upload_handler, []} {"/upload", upload_handler, []}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),
upload_sup:start_link(). upload_sup:start_link().

View file

@ -17,7 +17,7 @@ start(_Type, _Args) ->
{"/static/[...]", cowboy_static, {priv_dir, websocket, "static"}} {"/static/[...]", cowboy_static, {priv_dir, websocket, "static"}}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(http, 100, [{port, 8080}], #{ {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch} env => #{dispatch => Dispatch}
}), }),
websocket_sup:start_link(). websocket_sup:start_link().

View file

@ -1,4 +1,4 @@
{deps, [ {deps, [
{cowlib,".*",{git,"https://github.com/ninenines/cowlib","master"}},{ranch,".*",{git,"https://github.com/ninenines/ranch","1.3.0"}} {cowlib,".*",{git,"https://github.com/ninenines/cowlib","master"}},{ranch,".*",{git,"https://github.com/ninenines/ranch","1.4.0"}}
]}. ]}.
{erl_opts, [debug_info,warn_export_vars,warn_shadow_vars,warn_obsolete_guard,warn_export_all,warn_missing_spec,warn_untyped_record]}. {erl_opts, [debug_info,warn_export_vars,warn_shadow_vars,warn_obsolete_guard,warn_export_all,warn_missing_spec,warn_untyped_record]}.

View file

@ -14,8 +14,8 @@
-module(cowboy). -module(cowboy).
-export([start_clear/4]). -export([start_clear/3]).
-export([start_tls/4]). -export([start_tls/3]).
-export([stop_listener/1]). -export([stop_listener/1]).
-export([set_env/3]). -export([set_env/3]).
@ -37,27 +37,23 @@
-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]).
%% @todo We should hide NbAcceptors in a socket variable, even if Ranch -spec start_clear(ranch:ref(), ranch_tcp:opts(), opts())
%% doesn't let us do that yet.
-spec start_clear(ranch:ref(), non_neg_integer(), ranch_tcp:opts(), opts())
-> {ok, pid()} | {error, any()}. -> {ok, pid()} | {error, any()}.
start_clear(Ref, NbAcceptors, TransOpts0, ProtoOpts0) start_clear(Ref, TransOpts0, ProtoOpts0) ->
when is_integer(NbAcceptors), NbAcceptors > 0 ->
{TransOpts, ConnectionType} = ensure_connection_type(TransOpts0), {TransOpts, ConnectionType} = ensure_connection_type(TransOpts0),
ProtoOpts = ProtoOpts0#{connection_type => ConnectionType}, ProtoOpts = ProtoOpts0#{connection_type => ConnectionType},
ranch:start_listener(Ref, NbAcceptors, ranch_tcp, TransOpts, cowboy_clear, ProtoOpts). ranch:start_listener(Ref, ranch_tcp, TransOpts, cowboy_clear, ProtoOpts).
-spec start_tls(ranch:ref(), non_neg_integer(), ranch_ssl:opts(), opts()) -spec start_tls(ranch:ref(), ranch_ssl:opts(), opts())
-> {ok, pid()} | {error, any()}. -> {ok, pid()} | {error, any()}.
start_tls(Ref, NbAcceptors, TransOpts0, ProtoOpts0) start_tls(Ref, TransOpts0, ProtoOpts0) ->
when is_integer(NbAcceptors), NbAcceptors > 0 ->
{TransOpts1, ConnectionType} = ensure_connection_type(TransOpts0), {TransOpts1, ConnectionType} = ensure_connection_type(TransOpts0),
TransOpts = [ 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], |TransOpts1],
ProtoOpts = ProtoOpts0#{connection_type => ConnectionType}, ProtoOpts = ProtoOpts0#{connection_type => ConnectionType},
ranch:start_listener(Ref, NbAcceptors, ranch_ssl, TransOpts, cowboy_tls, ProtoOpts). ranch:start_listener(Ref, ranch_ssl, TransOpts, cowboy_tls, ProtoOpts).
ensure_connection_type(TransOpts) -> ensure_connection_type(TransOpts) ->
case proplists:get_value(connection_type, TransOpts) of case proplists:get_value(connection_type, TransOpts) of

View file

@ -20,19 +20,19 @@
%% Listeners initialization. %% Listeners initialization.
init_http(Ref, ProtoOpts, Config) -> init_http(Ref, ProtoOpts, Config) ->
{ok, _} = cowboy:start_clear(Ref, 100, [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(Ref, [{port, 0}], ProtoOpts),
Port = ranch:get_port(Ref), Port = ranch:get_port(Ref),
[{type, tcp}, {protocol, http}, {port, Port}, {opts, []}|Config]. [{type, tcp}, {protocol, http}, {port, Port}, {opts, []}|Config].
init_https(Ref, ProtoOpts, Config) -> init_https(Ref, ProtoOpts, Config) ->
Opts = ct_helper:get_certs_from_ets(), Opts = ct_helper:get_certs_from_ets(),
{ok, _} = cowboy:start_tls(Ref, 100, Opts ++ [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_tls(Ref, Opts ++ [{port, 0}], ProtoOpts),
Port = ranch:get_port(Ref), Port = ranch:get_port(Ref),
[{type, ssl}, {protocol, http}, {port, Port}, {opts, Opts}|Config]. [{type, ssl}, {protocol, http}, {port, Port}, {opts, Opts}|Config].
init_http2(Ref, ProtoOpts, Config) -> init_http2(Ref, ProtoOpts, Config) ->
Opts = ct_helper:get_certs_from_ets(), Opts = ct_helper:get_certs_from_ets(),
{ok, _} = cowboy:start_tls(Ref, 100, Opts ++ [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_tls(Ref, Opts ++ [{port, 0}], ProtoOpts),
Port = ranch:get_port(Ref), Port = ranch:get_port(Ref),
[{type, ssl}, {protocol, http2}, {port, Port}, {opts, Opts}|Config]. [{type, ssl}, {protocol, http2}, {port, Port}, {opts, Opts}|Config].

View file

@ -49,7 +49,7 @@ inactivity_timeout(Config) ->
env => #{dispatch => cowboy_router:compile(init_routes(Config))}, env => #{dispatch => cowboy_router:compile(init_routes(Config))},
inactivity_timeout => 1000 inactivity_timeout => 1000
}, },
{ok, _} = cowboy:start_clear(Ref, 100, [{port, 0}], ProtoOpts), {ok, _} = cowboy:start_clear(Ref, [{port, 0}], ProtoOpts),
Port = ranch:get_port(Ref), Port = ranch:get_port(Ref),
SocketConfig = [{type, tcp}, {protocol, http}, {port, Port}, {opts, []}|Config], SocketConfig = [{type, tcp}, {protocol, http}, {port, Port}, {opts, []}|Config],
{ok, Socket} = do_handshake(SocketConfig), {ok, Socket} = do_handshake(SocketConfig),

View file

@ -88,14 +88,14 @@ init_per_group(Name = https_compress, Config) ->
}, Config); }, Config);
%% Most, if not all of these, should be in separate test suites. %% Most, if not all of these, should be in separate test suites.
init_per_group(onresponse, Config) -> init_per_group(onresponse, Config) ->
{ok, _} = cowboy:start_clear(onresponse, 100, [{port, 0}], [ {ok, _} = cowboy:start_clear(onresponse, [{port, 0}], [
{env, [{dispatch, init_dispatch(Config)}]}, {env, [{dispatch, init_dispatch(Config)}]},
{onresponse, fun do_onresponse_hook/4} {onresponse, fun do_onresponse_hook/4}
]), ]),
Port = ranch:get_port(onresponse), Port = ranch:get_port(onresponse),
[{type, tcp}, {port, Port}, {opts, []}|Config]; [{type, tcp}, {port, Port}, {opts, []}|Config];
init_per_group(onresponse_capitalize, Config) -> init_per_group(onresponse_capitalize, Config) ->
{ok, _} = cowboy:start_clear(onresponse_capitalize, 100, [{port, 0}], [ {ok, _} = cowboy:start_clear(onresponse_capitalize, [{port, 0}], [
{env, [{dispatch, init_dispatch(Config)}]}, {env, [{dispatch, init_dispatch(Config)}]},
{onresponse, fun do_onresponse_capitalize_hook/4} {onresponse, fun do_onresponse_capitalize_hook/4}
]), ]),
@ -107,13 +107,13 @@ init_per_group(parse_host, Config) ->
{"/req_attr", http_req_attr, []} {"/req_attr", http_req_attr, []}
]} ]}
]), ]),
{ok, _} = cowboy:start_clear(parse_host, 100, [{port, 0}], [ {ok, _} = cowboy:start_clear(parse_host, [{port, 0}], [
{env, [{dispatch, Dispatch}]} {env, [{dispatch, Dispatch}]}
]), ]),
Port = ranch:get_port(parse_host), Port = ranch:get_port(parse_host),
[{type, tcp}, {port, Port}, {opts, []}|Config]; [{type, tcp}, {port, Port}, {opts, []}|Config];
init_per_group(set_env, Config) -> init_per_group(set_env, Config) ->
{ok, _} = cowboy:start_clear(set_env, 100, [{port, 0}], [ {ok, _} = cowboy:start_clear(set_env, [{port, 0}], [
{env, [{dispatch, []}]} {env, [{dispatch, []}]}
]), ]),
Port = ranch:get_port(set_env), Port = ranch:get_port(set_env),

View file

@ -38,7 +38,7 @@ init_per_group(Name = autobahn, Config) ->
"http://autobahn.ws/testsuite/installation.html"), "http://autobahn.ws/testsuite/installation.html"),
{skip, "Autobahn Test Suite not installed."}; {skip, "Autobahn Test Suite not installed."};
_ -> _ ->
{ok, _} = cowboy:start_clear(Name, 100, [{port, 33080}], #{ {ok, _} = cowboy:start_clear(Name, [{port, 33080}], #{
env => #{dispatch => init_dispatch()} env => #{dispatch => init_dispatch()}
}), }),
Config Config