From 8f257f121379ec831185ecf9b545b77a0b737a84 Mon Sep 17 00:00:00 2001 From: Mat Trudel Date: Thu, 30 Jan 2025 12:02:38 -0500 Subject: [PATCH] Consider HTTP/1 header read timeouts as connection errors --- lib/bandit/http1/socket.ex | 1 - test/bandit/http1/plug_test.exs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/bandit/http1/socket.ex b/lib/bandit/http1/socket.ex index 9157aade..3a5996ad 100644 --- a/lib/bandit/http1/socket.ex +++ b/lib/bandit/http1/socket.ex @@ -284,7 +284,6 @@ defmodule Bandit.HTTP1.Socket do defp read_available_for_header!(socket) do case ThousandIsland.Socket.recv(socket, 0) do {:ok, chunk} -> chunk - {:error, :timeout} -> request_error!("Header read timeout", :request_timeout) {:error, reason} -> socket_error!(reason) end end diff --git a/test/bandit/http1/plug_test.exs b/test/bandit/http1/plug_test.exs index 6f9c6110..721de7ab 100644 --- a/test/bandit/http1/plug_test.exs +++ b/test/bandit/http1/plug_test.exs @@ -652,7 +652,7 @@ defmodule HTTP1PlugTest do plug: {__MODULE__, []}, connection_telemetry_span_context: reference(), telemetry_span_context: reference(), - error: "Header read timeout" + error: "Unrecoverable error: timeout" } ) end