Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/plug/conn.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1436,9 +1436,12 @@ defmodule Plug.Conn do
end

defp adapter_inform(%Conn{adapter: {adapter, payload}}, status, headers) do
for {key, value} <- headers do
validate_header_key_value!(key, value)
end
headers =
for {key, value} <- headers do
key = to_string(key)
validate_header_key_value!(key, value)
{key, value}
end
Comment thread
josevalim marked this conversation as resolved.
Outdated

adapter.inform(payload, status, headers)
end
Expand Down
5 changes: 5 additions & 0 deletions test/plug/conn_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,11 @@
end
end

test "inform/3 accepts atom header keys (e.g. for websocket upgrades)" do

Check failure on line 471 in test/plug/conn_test.exs

View workflow job for this annotation

GitHub Actions / test (1.19, 28, lint, true)

test inform/3 accepts atom header keys (e.g. for websocket upgrades) (Plug.ConnTest)

Check failure on line 471 in test/plug/conn_test.exs

View workflow job for this annotation

GitHub Actions / test (1.15, 24, false)

test inform/3 accepts atom header keys (e.g. for websocket upgrades) (Plug.ConnTest)
conn = conn(:get, "/foo") |> inform(101, [{:upgrade, "websocket"}, {:connection, "Upgrade"}])
assert {101, [{:upgrade, "websocket"}, {:connection, "Upgrade"}]} in sent_informs(conn)
end

test "inform!/3 performs an informational request" do
conn = conn(:get, "/foo") |> inform!(103, [{"link", "</style.css>; rel=preload; as=style"}])
assert {103, [{"link", "</style.css>; rel=preload; as=style"}]} in sent_informs(conn)
Expand Down
Loading