From cd50a0d3f42afd5e12a1470902a60b4fa9d84f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 26 Jul 2019 15:25:53 +0200 Subject: Add the origin_changed event --- test/event_SUITE.erl | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/event_SUITE.erl b/test/event_SUITE.erl index d593a59..977eec4 100644 --- a/test/event_SUITE.erl +++ b/test/event_SUITE.erl @@ -822,7 +822,7 @@ ws_protocol_changed(Config) -> http1_protocol_changed_connect(Config) -> doc("Confirm that the protocol_changed event callback is called on CONNECT success " - "when connecting through a TLS server via a TCP proxy."), + "when connecting through a TCP server via a TCP proxy."), OriginPort = config(tcp_origin_port, Config), {ok, _, ProxyPort} = rfc7231_SUITE:do_proxy_start(tcp), {ok, ConnPid} = gun:open("localhost", ProxyPort, #{ @@ -905,6 +905,28 @@ http1_transport_changed_connect_over_https_proxy(Config) -> true = is_pid(Socket), gun:close(ConnPid). +http1_origin_changed_connect(Config) -> + doc("Confirm that the origin_changed event callback is called on CONNECT success."), + OriginPort = config(tcp_origin_port, Config), + {ok, _, ProxyPort} = rfc7231_SUITE:do_proxy_start(tcp), + {ok, ConnPid} = gun:open("localhost", ProxyPort, #{ + event_handler => {?MODULE, self()}, + protocols => [config(name, config(tc_group_properties, Config))], + transport => tcp + }), + {ok, http} = gun:await_up(ConnPid), + _ = gun:connect(ConnPid, #{ + host => "localhost", + port => OriginPort + }), + #{ + type := connect, + origin_scheme := <<"http">>, + origin_host := "localhost", + origin_port := OriginPort + } = do_receive_event(origin_changed), + gun:close(ConnPid). + cancel(Config) -> doc("Confirm that the cancel event callback is called when we cancel a stream."), {ok, Pid, _} = do_gun_open(Config), @@ -1095,6 +1117,10 @@ transport_changed(EventData, Pid) -> Pid ! {?FUNCTION_NAME, EventData}, Pid. +origin_changed(EventData, Pid) -> + Pid ! {?FUNCTION_NAME, EventData}, + Pid. + cancel(EventData, Pid) -> Pid ! {?FUNCTION_NAME, EventData}, Pid. -- cgit v1.2.3