From 31ccd848b14c029a40880cc95582be88e6ba74aa Mon Sep 17 00:00:00 2001 From: Giovanni Barillari Date: Wed, 24 Jan 2024 16:34:16 +0100 Subject: [PATCH 1/5] Fix main file --- emmett/__main__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/emmett/__main__.py b/emmett/__main__.py index d4b7ad2d..6dedb24f 100644 --- a/emmett/__main__.py +++ b/emmett/__main__.py @@ -9,7 +9,6 @@ :license: BSD-3-Clause """ -if __name__ == "__main__": - from .cli import main +from emmett.cli import main - main(as_module=True) +main(as_module=True) From 28f8b54accad7d7e6f6342246f856a3849a9e98a Mon Sep 17 00:00:00 2001 From: Giovanni Barillari Date: Sun, 28 Jan 2024 16:01:27 +0100 Subject: [PATCH 2/5] Bump version to 2.5.9 --- emmett/__version__.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emmett/__version__.py b/emmett/__version__.py index 2e6e020c..472aa8d1 100644 --- a/emmett/__version__.py +++ b/emmett/__version__.py @@ -1 +1 @@ -__version__ = "2.5.8" +__version__ = "2.5.9" diff --git a/pyproject.toml b/pyproject.toml index 24c4949b..68c0748a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "emmett" [tool.poetry] name = "emmett" -version = "2.5.8" +version = "2.5.9" description = "The web framework for inventors" authors = ["Giovanni Barillari "] license = "BSD-3-Clause" From f14ae9329e8c62e03ee36008060e253de5c6e674 Mon Sep 17 00:00:00 2001 From: Giovanni Barillari Date: Sun, 28 Jan 2024 16:03:03 +0100 Subject: [PATCH 3/5] Bump granian to 1.0.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 68c0748a..0986e5e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ emmett = "emmett.cli:main" [tool.poetry.dependencies] python = "^3.8" click = ">=6.0" -granian = "~1.0.0" +granian = "~1.0.2" emmett-crypto = "^0.5" pendulum = "~3.0.0" pyDAL = "17.3" From 7a3fec0dab2f6e72b84cc1464e30c2adceddc2f9 Mon Sep 17 00:00:00 2001 From: Giovanni Barillari Date: Sun, 28 Jan 2024 16:03:47 +0100 Subject: [PATCH 4/5] Avoid exceptions in ASGI `HTTPFile` response in case of missing scope extensions --- emmett/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emmett/http.py b/emmett/http.py index da44e28b..c96aa3ea 100644 --- a/emmett/http.py +++ b/emmett/http.py @@ -221,7 +221,7 @@ async def asgi(self, scope, send): return self._headers.update(self._get_stat_headers(stat_data)) await self._send_headers(send) - if 'http.response.pathsend' in scope['extensions']: + if 'http.response.pathsend' in scope.get('extensions', {}): await send({ 'type': 'http.response.pathsend', 'path': str(self.file_path) From 6a409a1aef16beaa3497bb750ac78bca98a90c1e Mon Sep 17 00:00:00 2001 From: Giovanni Barillari Date: Sun, 28 Jan 2024 16:04:19 +0100 Subject: [PATCH 5/5] Patch `Request.host` in RSGI HTTP/2 --- emmett/rsgi/wrappers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/emmett/rsgi/wrappers.py b/emmett/rsgi/wrappers.py index e6a189b6..0de63011 100644 --- a/emmett/rsgi/wrappers.py +++ b/emmett/rsgi/wrappers.py @@ -42,6 +42,12 @@ def __init__( def headers(self): return self._scope.headers + @cachedprop + def host(self) -> str: + if self._scope.http_version[0] == '1': + return self.headers.get('host') + return self._scope.authority + @cachedprop def query_params(self) -> sdict[str, Union[str, List[str]]]: rv: sdict[str, Any] = sdict()