From fa5ad7c56f670152eaa0869815b8b0dfb2527ab8 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Tue, 25 Jan 2022 08:21:42 +0100 Subject: [PATCH] Fix spec_version value from WebSocket and HTTP connection scopes (#1337) --- tests/protocols/test_http.py | 4 ++-- uvicorn/protocols/http/h11_impl.py | 2 +- uvicorn/protocols/http/httptools_impl.py | 2 +- uvicorn/protocols/websockets/websockets_impl.py | 2 +- uvicorn/protocols/websockets/wsproto_impl.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/protocols/test_http.py b/tests/protocols/test_http.py index 826f05fdc..b784c5e9b 100644 --- a/tests/protocols/test_http.py +++ b/tests/protocols/test_http.py @@ -710,8 +710,8 @@ async def asgi(receive, send): asgi_scope_data = [ - (asgi3app, {"version": "3.0", "spec_version": "2.1"}), - (asgi2app, {"version": "2.0", "spec_version": "2.1"}), + (asgi3app, {"version": "3.0", "spec_version": "2.3"}), + (asgi2app, {"version": "2.0", "spec_version": "2.3"}), ] diff --git a/uvicorn/protocols/http/h11_impl.py b/uvicorn/protocols/http/h11_impl.py index 04b997ffe..76af34393 100644 --- a/uvicorn/protocols/http/h11_impl.py +++ b/uvicorn/protocols/http/h11_impl.py @@ -159,7 +159,7 @@ def handle_events(self): "type": "http", "asgi": { "version": self.config.asgi_version, - "spec_version": "2.1", + "spec_version": "2.3", }, "http_version": event.http_version.decode("ascii"), "server": self.server, diff --git a/uvicorn/protocols/http/httptools_impl.py b/uvicorn/protocols/http/httptools_impl.py index 33e21dc3b..34f66c97c 100644 --- a/uvicorn/protocols/http/httptools_impl.py +++ b/uvicorn/protocols/http/httptools_impl.py @@ -201,7 +201,7 @@ def on_url(self, url): self.headers = [] self.scope = { "type": "http", - "asgi": {"version": self.config.asgi_version, "spec_version": "2.1"}, + "asgi": {"version": self.config.asgi_version, "spec_version": "2.3"}, "http_version": "1.1", "server": self.server, "client": self.client, diff --git a/uvicorn/protocols/websockets/websockets_impl.py b/uvicorn/protocols/websockets/websockets_impl.py index 95875b1e3..dedc2dd10 100644 --- a/uvicorn/protocols/websockets/websockets_impl.py +++ b/uvicorn/protocols/websockets/websockets_impl.py @@ -132,7 +132,7 @@ async def process_request(self, path, headers): self.scope = { "type": "websocket", - "asgi": {"version": self.config.asgi_version, "spec_version": "2.1"}, + "asgi": {"version": self.config.asgi_version, "spec_version": "2.3"}, "http_version": "1.1", "scheme": self.scheme, "server": self.server, diff --git a/uvicorn/protocols/websockets/wsproto_impl.py b/uvicorn/protocols/websockets/wsproto_impl.py index bf4c90441..85fa58899 100644 --- a/uvicorn/protocols/websockets/wsproto_impl.py +++ b/uvicorn/protocols/websockets/wsproto_impl.py @@ -146,7 +146,7 @@ def handle_connect(self, event): raw_path, _, query_string = event.target.partition("?") self.scope = { "type": "websocket", - "asgi": {"version": self.config.asgi_version, "spec_version": "2.1"}, + "asgi": {"version": self.config.asgi_version, "spec_version": "2.3"}, "http_version": "1.1", "scheme": self.scheme, "server": self.server,