fix: dont log BrokenPipeError and ConnectionResetError
This commit is contained in:
@@ -300,6 +300,8 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler, BaseHandler):
|
|||||||
self.__target_spa: str | None = None
|
self.__target_spa: str | None = None
|
||||||
try:
|
try:
|
||||||
super().__init__(*args, directory=params.data_dir, **kwargs, params=params) # ty:ignore[unknown-argument]
|
super().__init__(*args, directory=params.data_dir, **kwargs, params=params) # ty:ignore[unknown-argument]
|
||||||
|
except (BrokenPipeError, ConnectionResetError) as e:
|
||||||
|
self.logger.error("Connection lost: %s", str(e)) # noqa: TRY400
|
||||||
except:
|
except:
|
||||||
self.logger.exception("Could not handle request")
|
self.logger.exception("Could not handle request")
|
||||||
|
|
||||||
|
|||||||
@@ -177,6 +177,21 @@ class TestRequestHandler(BaseHandlerTestCase):
|
|||||||
token_manager=self.token_manager,
|
token_manager=self.token_manager,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_handle_disconnect_silently(self) -> None:
|
||||||
|
with self.patch("http.server.BaseHTTPRequestHandler.__init__") as mock:
|
||||||
|
mock.side_effect = BrokenPipeError
|
||||||
|
logging.basicConfig(level=logging.CRITICAL)
|
||||||
|
RequestHandler(
|
||||||
|
unittest.mock.MagicMock(),
|
||||||
|
"127.0.0.1",
|
||||||
|
unittest.mock.MagicMock(),
|
||||||
|
params=Parameters(
|
||||||
|
data_dir=self.get_tmp_dir(), certbot_www=str(self.certbot_www)
|
||||||
|
),
|
||||||
|
registry=self.registry,
|
||||||
|
token_manager=self.token_manager,
|
||||||
|
)
|
||||||
|
|
||||||
def test_do_head_forward(self) -> None:
|
def test_do_head_forward(self) -> None:
|
||||||
handler = self._get_handler()
|
handler = self._get_handler()
|
||||||
with (
|
with (
|
||||||
|
|||||||
Reference in New Issue
Block a user