fix: force upgrade for all http methods
Python Lint CI / ruff-format-check (push) Successful in 1m2s
Python Lint CI / ruff (push) Successful in 1m4s
Python Lint CI / ty (push) Successful in 1m10s
Docker CI / docker-build (push) Successful in 2m32s
Python Test CI / coverage (push) Successful in 3m26s

This commit is contained in:
2026-06-03 18:59:59 +02:00
parent c5f3e53d88
commit ada69f773e
2 changed files with 36 additions and 14 deletions
+21
View File
@@ -689,3 +689,24 @@ class UpgradeHandler(RequestHandler):
self.close_connection = True
else:
self.do_HEAD()
def do_POST(self) -> None:
self.do_HEAD()
def do_PUT(self) -> None:
self.do_HEAD()
def do_DELETE(self) -> None:
self.do_HEAD()
def do_OPTIONS(self) -> None:
self.do_HEAD()
def do_PATCH(self) -> None:
self.do_HEAD()
def do_CONNECT(self) -> None:
self.do_HEAD()
def do_TRACE(self) -> None:
self.do_HEAD()
+15 -14
View File
@@ -1358,21 +1358,22 @@ class TestUpgradeHandler(BaseHandlerTestCase):
handler.data_dir = self.data_dir
return handler
def test_do_get(self) -> None:
def test_do_upgrade(self) -> None:
handler = self._get_handler("/file")
with (
self.expects_status_only(
handler,
http.HTTPStatus.MOVED_PERMANENTLY,
headers={"Location": "https://localhost/file"},
),
self.patch(
"http.server.SimpleHTTPRequestHandler.do_GET",
count=0,
),
self.seal_mocks(),
):
handler.do_GET()
for method in [method.value for method in http.HTTPMethod]:
with (
self.subTest(None, method=method),
self.expects_status_only(
handler,
http.HTTPStatus.MOVED_PERMANENTLY,
headers={"Location": "https://localhost/file"},
),
self.patch(
f"http.server.SimpleHTTPRequestHandler.do_{method}", count=0
),
self.seal_mocks(),
):
getattr(handler, f"do_{method}")()
def test_do_get_certbot(self) -> None:
handler = self._get_handler("/.well-known/acme-challenge/abcde")