Skip to content

Commit

Permalink
Merge branch '1.2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrudel committed Feb 16, 2024
2 parents e21255a + ed6e94e commit e2128ca
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
## 1.2.1 (12 Fed 2024)
## 1.2.2 (16 Feb 2024)

### Changes

* Reset Logger metadata on every request

## 1.2.1 (12 Feb 2024)

### Changes

Expand Down
2 changes: 2 additions & 0 deletions lib/bandit/pipeline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defmodule Bandit.Pipeline do
plug_def()
) :: {:ok, Plug.Conn.t()} | {:ok, :websocket, Plug.Conn.t(), tuple()} | {:error, term()}
def run(req, transport_info, method, request_target, headers, plug) do
Logger.reset_metadata()

with {:ok, conn} <- build_conn(req, transport_info, method, request_target, headers),
conn <- call_plug(conn, plug),
{:ok, :no_upgrade} <- maybe_upgrade(conn) do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Bandit.MixProject do
def project do
[
app: :bandit,
version: "1.2.1",
version: "1.2.2",
elixir: "~> 1.13",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down
16 changes: 16 additions & 0 deletions test/bandit/http1/request_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ defmodule HTTP1RequestTest do
def echo_method(conn) do
send_resp(conn, 200, conn.method)
end

test "logger metadata is reset on every request", context do
client = SimpleHTTP1Client.tcp_client(context)

SimpleHTTP1Client.send(client, "GET", "/metadata", ["host: localhost"])
assert {:ok, "200 OK", _headers, "[]"} = SimpleHTTP1Client.recv_reply(client)

SimpleHTTP1Client.send(client, "GET", "/metadata", ["host: localhost"])
assert {:ok, "200 OK", _headers, "[]"} = SimpleHTTP1Client.recv_reply(client)
end

def metadata(conn) do
existing_metadata = Logger.metadata()
Logger.metadata(add: :garbage)

Check warning on line 124 in test/bandit/http1/request_test.exs

View workflow job for this annotation

GitHub Actions / lint / lint (1.15.x, 26.x)

Logger metadata key add not found in Logger config
send_resp(conn, 200, inspect(existing_metadata))
end
end

describe "origin-form request target (RFC9112§3.2.1)" do
Expand Down

0 comments on commit e2128ca

Please sign in to comment.