aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndrei Nesterov <[email protected]>2016-11-16 20:57:11 +0300
committerLoïc Hoguin <[email protected]>2017-05-01 17:31:56 +0200
commit0a181681223aead4043b2437fe493652db6e5f8a (patch)
tree807f4b07b0a1995f7c40af1fde1ad9b330a0ba31 /test
parentfb4bd38ffd2c330cbd677d958477aa909210a0b3 (diff)
downloadgun-0a181681223aead4043b2437fe493652db6e5f8a.tar.gz
gun-0a181681223aead4043b2437fe493652db6e5f8a.tar.bz2
gun-0a181681223aead4043b2437fe493652db6e5f8a.zip
Add support for choosing a process to reply to
Diffstat (limited to 'test')
-rw-r--r--test/gun_SUITE.erl26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl
index 64b8885..171c874 100644
--- a/test/gun_SUITE.erl
+++ b/test/gun_SUITE.erl
@@ -75,6 +75,32 @@ gone_reason(_) ->
error(timeout)
end.
+reply_to(_) ->
+ doc("The reply_to option allows using a separate process for requests."),
+ do_reply_to(http),
+ do_reply_to(http2).
+
+do_reply_to(Protocol) ->
+ Self = self(),
+ {ok, Pid} = gun:open("google.com", 443, #{protocols => [Protocol]}),
+ {ok, Protocol} = gun:await_up(Pid),
+ ReplyTo = spawn(fun() ->
+ receive Ref ->
+ Response = gun:await(Pid, Ref),
+ Self ! Response
+ after 1000 ->
+ error(timeout)
+ end
+ end),
+ Ref = gun:get(Pid, "/", [{<<"host">>, <<"google.com">>}], #{reply_to => ReplyTo}),
+ ReplyTo ! Ref,
+ receive
+ {response, _, _, _} ->
+ ok
+ after 1000 ->
+ error(timeout)
+ end.
+
retry_0(_) ->
doc("Ensure Gun gives up immediately with retry=0."),
{ok, Pid} = gun:open("localhost", 12345, #{retry => 0, retry_timeout => 500}),