feat: handle HEAD requests
This commit is contained in:
+15
-2
@@ -36,6 +36,7 @@ class BaseHandlerTestCase(BaseTestCase, abc.ABC):
|
||||
code: int,
|
||||
message: str | None = None,
|
||||
headers: dict[str, str] | None = None,
|
||||
content_length: int = 0,
|
||||
) -> typing.Iterator[None]:
|
||||
if headers is None:
|
||||
headers = {}
|
||||
@@ -46,7 +47,7 @@ class BaseHandlerTestCase(BaseTestCase, abc.ABC):
|
||||
send_response_mock.assert_called_once_with(code, message)
|
||||
send_header_mock.assert_has_calls(
|
||||
[
|
||||
unittest.mock.call("Content-Length", "0"),
|
||||
unittest.mock.call("Content-Length", str(content_length)),
|
||||
]
|
||||
+ [unittest.mock.call(header, value) for header, value in headers.items()],
|
||||
any_order=True,
|
||||
@@ -192,9 +193,21 @@ class TestRequestHandler(BaseHandlerTestCase):
|
||||
token_manager=self.token_manager,
|
||||
)
|
||||
|
||||
def test_do_head_forward(self) -> None:
|
||||
def test_do_head_index(self) -> None:
|
||||
handler = self._get_handler()
|
||||
with (
|
||||
self.expects_status_only(
|
||||
handler, 200, content_length=len(handler.server_signature())
|
||||
),
|
||||
self.patch("http.server.SimpleHTTPRequestHandler.do_HEAD", count=0),
|
||||
self.seal_mocks(),
|
||||
):
|
||||
handler.do_HEAD()
|
||||
|
||||
def test_do_head_forward(self) -> None:
|
||||
handler = self._get_handler("/file")
|
||||
with (
|
||||
self.mock_call(self.registry.get_from_path, ["file"], Page("file")),
|
||||
self.patch("http.server.SimpleHTTPRequestHandler.do_HEAD"),
|
||||
self.seal_mocks(),
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user