From fc6c51b8bba48454685907ba629ca404543e9f42 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 20 Nov 2024 20:19:24 +0100 Subject: [PATCH] Drop ASGI spec version to 2.3 on HTTP (#2513) --- tests/protocols/test_http.py | 4 ++-- uvicorn/protocols/http/h11_impl.py | 5 +---- uvicorn/protocols/http/httptools_impl.py | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/protocols/test_http.py b/tests/protocols/test_http.py index b3b060b0f..d8711af5b 100644 --- a/tests/protocols/test_http.py +++ b/tests/protocols/test_http.py @@ -860,8 +860,8 @@ async def asgi(receive: ASGIReceiveCallable, send: ASGISendCallable): @pytest.mark.parametrize( "asgi2or3_app, expected_scopes", [ - (asgi3app, {"version": "3.0", "spec_version": "2.4"}), - (asgi2app, {"version": "2.0", "spec_version": "2.4"}), + (asgi3app, {"version": "3.0", "spec_version": "2.3"}), + (asgi2app, {"version": "2.0", "spec_version": "2.3"}), ], ) async def test_scopes( diff --git a/uvicorn/protocols/http/h11_impl.py b/uvicorn/protocols/http/h11_impl.py index 932ddf62b..b8cdde3ab 100644 --- a/uvicorn/protocols/http/h11_impl.py +++ b/uvicorn/protocols/http/h11_impl.py @@ -200,10 +200,7 @@ def handle_events(self) -> None: full_raw_path = self.root_path.encode("ascii") + raw_path self.scope = { "type": "http", - "asgi": { - "version": self.config.asgi_version, - "spec_version": "2.4", - }, + "asgi": {"version": self.config.asgi_version, "spec_version": "2.3"}, "http_version": event.http_version.decode("ascii"), "server": self.server, "client": self.client, diff --git a/uvicorn/protocols/http/httptools_impl.py b/uvicorn/protocols/http/httptools_impl.py index f3396a768..e8795ed35 100644 --- a/uvicorn/protocols/http/httptools_impl.py +++ b/uvicorn/protocols/http/httptools_impl.py @@ -222,7 +222,7 @@ def on_message_begin(self) -> None: self.headers = [] self.scope = { # type: ignore[typeddict-item] "type": "http", - "asgi": {"version": self.config.asgi_version, "spec_version": "2.4"}, + "asgi": {"version": self.config.asgi_version, "spec_version": "2.3"}, "http_version": "1.1", "server": self.server, "client": self.client,