aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2021-02-09 14:36:39 +0100
committerLoïc Hoguin <[email protected]>2021-02-09 14:36:39 +0100
commit52b989079bacf423818a8e6d42c56095ad857635 (patch)
tree5a661c7b7953035d662e93c26c18eacbd9bca2db
parent53205a26d9cbbc09b9b31cf7005293ac9d99eaae (diff)
downloadgun-52b989079bacf423818a8e6d42c56095ad857635.tar.gz
gun-52b989079bacf423818a8e6d42c56095ad857635.tar.bz2
gun-52b989079bacf423818a8e6d42c56095ad857635.zip
Fix gun_pool:stop_pool/2,3 with default port
-rw-r--r--src/gun_pool.erl13
-rw-r--r--test/pool_SUITE.erl7
2 files changed, 17 insertions, 3 deletions
diff --git a/src/gun_pool.erl b/src/gun_pool.erl
index da31a42..8c40788 100644
--- a/src/gun_pool.erl
+++ b/src/gun_pool.erl
@@ -165,10 +165,17 @@ start_pool(Host, Port, Opts) ->
stop_pool(Host, Port) ->
stop_pool(Host, Port, #{}).
--spec stop_pool(inet:hostname() | inet:ip_address(), inet:port_number(), req_opts())
+-type stop_opts() :: #{
+ scope => any(),
+ transport => tcp | tls
+}.
+
+-spec stop_pool(inet:hostname() | inet:ip_address(), inet:port_number(), stop_opts())
-> ok | {error, pool_not_found, atom()}.
-stop_pool(Host, Port, ReqOpts) ->
- case get_pool(iolist_to_binary([Host, $:, integer_to_binary(Port)]), ReqOpts) of
+stop_pool(Host, Port, StopOpts) ->
+ Transport = maps:get(transport, StopOpts, gun:default_transport(Port)),
+ Authority = gun_http:host_header(Transport, Host, Port),
+ case get_pool(Authority, StopOpts) of
undefined ->
{error, pool_not_found,
'No pool was found for the given scope and authority.'};
diff --git a/test/pool_SUITE.erl b/test/pool_SUITE.erl
index a48b75d..7643368 100644
--- a/test/pool_SUITE.erl
+++ b/test/pool_SUITE.erl
@@ -374,3 +374,10 @@ reconnect_h2(Config) ->
end || {async, StreamRef} <- Streams2].
%% @todo reconnect_ws
+
+stop_pool(Config) ->
+ doc("Confirm the pool can be used for HTTP/1.1 connections."),
+ Port = config(port, Config),
+ {ok, ManagerPid} = gun_pool:start_pool("localhost", Port, #{scope => ?FUNCTION_NAME}),
+ gun_pool:await_up(ManagerPid),
+ gun_pool:stop_pool("localhost", Port, #{scope => ?FUNCTION_NAME}).