aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun.erl
diff options
context:
space:
mode:
authorrinpatch <[email protected]>2020-09-24 00:06:51 +0300
committerLoïc Hoguin <[email protected]>2020-10-07 11:12:59 +0200
commitc2c0203a5c1e8bcf14b7a26d53c3cb7cc6fd565b (patch)
tree758d20bf40a2046a5146b7f6954cdee60bfd2f46 /src/gun.erl
parent2f4046c13213ed2cd7d51d6422e74170bf22d2fc (diff)
downloadgun-c2c0203a5c1e8bcf14b7a26d53c3cb7cc6fd565b.tar.gz
gun-c2c0203a5c1e8bcf14b7a26d53c3cb7cc6fd565b.tar.bz2
gun-c2c0203a5c1e8bcf14b7a26d53c3cb7cc6fd565b.zip
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.
Diffstat (limited to 'src/gun.erl')
-rw-r--r--src/gun.erl4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gun.erl b/src/gun.erl
index 047aa18..bd4ce3d 100644
--- a/src/gun.erl
+++ b/src/gun.erl
@@ -920,7 +920,7 @@ ws_upgrade(ServerPid, Path) ->
-spec ws_upgrade(pid(), iodata(), req_headers()) -> stream_ref().
ws_upgrade(ServerPid, Path, Headers) ->
StreamRef = make_ref(),
- gen_statem:cast(ServerPid, {ws_upgrade, self(), StreamRef, Path, Headers}),
+ gen_statem:cast(ServerPid, {ws_upgrade, self(), StreamRef, Path, normalize_headers(Headers)}),
StreamRef.
-spec ws_upgrade(pid(), iodata(), req_headers(), ws_opts()) -> stream_ref().
@@ -929,7 +929,7 @@ ws_upgrade(ServerPid, Path, Headers, Opts) ->
StreamRef = make_ref(),
ReplyTo = maps:get(reply_to, Opts, self()),
%% @todo Also accept tunnel option.
- gen_statem:cast(ServerPid, {ws_upgrade, ReplyTo, StreamRef, Path, Headers, Opts}),
+ gen_statem:cast(ServerPid, {ws_upgrade, ReplyTo, StreamRef, Path, normalize_headers(Headers), Opts}),
StreamRef.
%% @todo ws_send/2 will need to be deprecated in favor of a variant with StreamRef.