Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.

Commit d20255a

Browse files
committed
Explicitly send a response.
1 parent 1356f76 commit d20255a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/plug_require_header.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ defmodule PlugRequireHeader do
4343

4444
defp halt_connection(conn) do
4545
conn
46-
|> put_status(Status.code :forbidden)
46+
|> send_resp(Status.code(:forbidden), "")
4747
|> halt
4848
end
4949
end

test/plug_require_header_test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@ defmodule PlugRequireHeaderTest do
1010
response = TestApp.call(connection, @options)
1111

1212
assert response.status == Status.code(:forbidden)
13+
assert response.resp_body == ""
1314
end
1415

1516
test "block request with a header set, but without the required header" do
1617
connection = conn(:get, "/") |> put_req_header("x-wrong-header", "whatever")
1718
response = TestApp.call(connection, @options)
1819

1920
assert response.status == Status.code(:forbidden)
21+
assert response.resp_body == ""
2022
end
2123

2224
test "block request with the required header set to nil" do
2325
connection = conn(:get, "/") |> put_nil_header("x-api-key")
2426
response = TestApp.call(connection, @options)
2527

2628
assert response.status == Status.code(:forbidden)
29+
assert response.resp_body == ""
2730
end
2831

2932
test "extract the required header and assign it to the connection" do

0 commit comments

Comments
 (0)