From c2c0203a5c1e8bcf14b7a26d53c3cb7cc6fd565b Mon Sep 17 00:00:00 2001 From: rinpatch Date: Thu, 24 Sep 2020 00:06:51 +0300 Subject: Normalize headers in ws_upgrade In the documentation headers passed to ws_upgrade are typed as gun:req_headers(), however if a map of headers is passed (which is allowed by the type), the gun process will crash when trying to operate on it as if it were a list. --- test/ws_SUITE.erl | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/ws_SUITE.erl') diff --git a/test/ws_SUITE.erl b/test/ws_SUITE.erl index d4413fb..c04acc2 100644 --- a/test/ws_SUITE.erl +++ b/test/ws_SUITE.erl @@ -70,6 +70,17 @@ error_http10_upgrade(Config) -> error(timeout) end. +headers_normalized_upgrade(Config) -> + doc("Headers passed to ws_upgrade are normalized before being used."), + {ok, ConnPid} = gun:open("localhost", config(port, Config)), + {ok, _} = gun:await_up(ConnPid), + StreamRef = gun:ws_upgrade(ConnPid, "/", #{ + atom_header_name => <<"value">>, + "string_header_name" => <<"value">> + }), + {upgrade, [<<"websocket">>], _} = gun:await(ConnPid, StreamRef), + gun:close(ConnPid). + error_http_request(Config) -> doc("Ensure that requests are rejected while using Websocket."), {ok, ConnPid} = gun:open("localhost", config(port, Config)), -- cgit v1.2.3