Skip to content

Commit 9df2c0a

Browse files
authored
Allow atom header keys in inform/3 (#1318)
1 parent d8d733b commit 9df2c0a

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/plug/conn.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ defmodule Plug.Conn do
14371437

14381438
defp adapter_inform(%Conn{adapter: {adapter, payload}}, status, headers) do
14391439
for {key, value} <- headers do
1440-
validate_header_key_value!(key, value)
1440+
validate_header_key_value!(to_string(key), value)
14411441
end
14421442

14431443
adapter.inform(payload, status, headers)

test/plug/conn_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,11 @@ defmodule Plug.ConnTest do
468468
end
469469
end
470470

471+
test "inform/3 accepts atom header keys (e.g. for websocket upgrades)" do
472+
conn = conn(:get, "/foo") |> inform(101, [{:upgrade, "websocket"}, {:connection, "Upgrade"}])
473+
assert {101, [{:upgrade, "websocket"}, {:connection, "Upgrade"}]} in sent_informs(conn)
474+
end
475+
471476
test "inform!/3 performs an informational request" do
472477
conn = conn(:get, "/foo") |> inform!(103, [{"link", "</style.css>; rel=preload; as=style"}])
473478
assert {103, [{"link", "</style.css>; rel=preload; as=style"}]} in sent_informs(conn)

0 commit comments

Comments
 (0)