summaryrefslogtreecommitdiff
path: root/venv/lib/python3.11/site-packages/litestar/_layers
diff options
context:
space:
mode:
Diffstat (limited to 'venv/lib/python3.11/site-packages/litestar/_layers')
-rw-r--r--venv/lib/python3.11/site-packages/litestar/_layers/__init__.py0
-rw-r--r--venv/lib/python3.11/site-packages/litestar/_layers/__pycache__/__init__.cpython-311.pycbin0 -> 200 bytes
-rw-r--r--venv/lib/python3.11/site-packages/litestar/_layers/__pycache__/utils.cpython-311.pycbin0 -> 2457 bytes
-rw-r--r--venv/lib/python3.11/site-packages/litestar/_layers/utils.py34
4 files changed, 34 insertions, 0 deletions
diff --git a/venv/lib/python3.11/site-packages/litestar/_layers/__init__.py b/venv/lib/python3.11/site-packages/litestar/_layers/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/venv/lib/python3.11/site-packages/litestar/_layers/__init__.py
diff --git a/venv/lib/python3.11/site-packages/litestar/_layers/__pycache__/__init__.cpython-311.pyc b/venv/lib/python3.11/site-packages/litestar/_layers/__pycache__/__init__.cpython-311.pyc
new file mode 100644
index 0000000..7b7425e
--- /dev/null
+++ b/venv/lib/python3.11/site-packages/litestar/_layers/__pycache__/__init__.cpython-311.pyc
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/litestar/_layers/__pycache__/utils.cpython-311.pyc b/venv/lib/python3.11/site-packages/litestar/_layers/__pycache__/utils.cpython-311.pyc
new file mode 100644
index 0000000..d772e10
--- /dev/null
+++ b/venv/lib/python3.11/site-packages/litestar/_layers/__pycache__/utils.cpython-311.pyc
Binary files differ
diff --git a/venv/lib/python3.11/site-packages/litestar/_layers/utils.py b/venv/lib/python3.11/site-packages/litestar/_layers/utils.py
new file mode 100644
index 0000000..61afd61
--- /dev/null
+++ b/venv/lib/python3.11/site-packages/litestar/_layers/utils.py
@@ -0,0 +1,34 @@
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Mapping, Sequence
+
+from litestar.datastructures.cookie import Cookie
+from litestar.datastructures.response_header import ResponseHeader
+
+__all__ = ("narrow_response_cookies", "narrow_response_headers")
+
+
+if TYPE_CHECKING:
+ from litestar.types.composite_types import ResponseCookies, ResponseHeaders
+
+
+def narrow_response_headers(headers: ResponseHeaders | None) -> Sequence[ResponseHeader] | None:
+ """Given :class:`.types.ResponseHeaders` as a :class:`typing.Mapping`, create a list of
+ :class:`.datastructures.response_header.ResponseHeader` from it, otherwise return ``headers`` unchanged
+ """
+ return (
+ tuple(ResponseHeader(name=name, value=value) for name, value in headers.items())
+ if isinstance(headers, Mapping)
+ else headers
+ )
+
+
+def narrow_response_cookies(cookies: ResponseCookies | None) -> Sequence[Cookie] | None:
+ """Given :class:`.types.ResponseCookies` as a :class:`typing.Mapping`, create a list of
+ :class:`.datastructures.cookie.Cookie` from it, otherwise return ``cookies`` unchanged
+ """
+ return (
+ tuple(Cookie(key=key, value=value) for key, value in cookies.items())
+ if isinstance(cookies, Mapping)
+ else cookies
+ )