]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Revert "Add support for ASGI `pathsend` extension" (#2649)
authorGiovanni Barillari <giovanni.barillari@sentry.io>
Tue, 23 Jul 2024 10:10:14 +0000 (12:10 +0200)
committerGitHub <noreply@github.com>
Tue, 23 Jul 2024 10:10:14 +0000 (04:10 -0600)
This reverts commit 7936e86f0a0eb7494aee8a1094b0ccda31c67a72.

starlette/responses.py
tests/test_responses.py

index bd66f897efd7000d81d790f17e95894a2d0d62e2..1f41c23d4c3b895c91a9a5bfc518da8c1b69abaa 100644 (file)
@@ -341,8 +341,6 @@ class FileResponse(Response):
         )
         if scope["method"].upper() == "HEAD":
             await send({"type": "http.response.body", "body": b"", "more_body": False})
-        elif "extensions" in scope and "http.response.pathsend" in scope["extensions"]:
-            await send({"type": "http.response.pathsend", "path": str(self.path)})
         else:
             async with await anyio.open_file(self.path, mode="rb") as file:
                 more_body = True
index 434cc5a22598a00797d7de9409d7be4e53f9e10a..c134cbda513ee4ee149d108dffce33d81e70e388 100644 (file)
@@ -350,38 +350,6 @@ def test_file_response_with_method_warns(
         FileResponse(path=tmpdir, filename="example.png", method="GET")
 
 
-@pytest.mark.anyio
-async def test_file_response_with_pathsend(tmpdir: Path) -> None:
-    path = os.path.join(tmpdir, "xyz")
-    content = b"<file content>" * 1000
-    with open(path, "wb") as file:
-        file.write(content)
-
-    app = FileResponse(path=path, filename="example.png")
-
-    async def receive() -> Message:  # type: ignore[empty-body]
-        ...  # pragma: no cover
-
-    async def send(message: Message) -> None:
-        if message["type"] == "http.response.start":
-            assert message["status"] == status.HTTP_200_OK
-            headers = Headers(raw=message["headers"])
-            assert headers["content-type"] == "image/png"
-            assert "content-length" in headers
-            assert "content-disposition" in headers
-            assert "last-modified" in headers
-            assert "etag" in headers
-        elif message["type"] == "http.response.pathsend":
-            assert message["path"] == str(path)
-
-    # Since the TestClient doesn't support `pathsend`, we need to test this directly.
-    await app(
-        {"type": "http", "method": "get", "extensions": {"http.response.pathsend": {}}},
-        receive,
-        send,
-    )
-
-
 def test_set_cookie(
     test_client_factory: TestClientFactory, monkeypatch: pytest.MonkeyPatch
 ) -> None: