diff --git a/sanic/asgi.py b/sanic/asgi.py index e9bcf2de..9e5e5e65 100644 --- a/sanic/asgi.py +++ b/sanic/asgi.py @@ -5,8 +5,7 @@ from inspect import isawaitable from typing import Any, Awaitable, Callable, MutableMapping, Union from urllib.parse import quote -from multidict import CIMultiDict - +from sanic.compat import Header from sanic.exceptions import InvalidUsage, ServerError from sanic.log import logger from sanic.request import Request @@ -186,7 +185,7 @@ class ASGIApp: instance.transport.add_task = sanic_app.loop.create_task instance.transport.loop = sanic_app.loop - headers = CIMultiDict( + headers = Header( [ (key.decode("latin-1"), value.decode("latin-1")) for key, value in scope.get("headers", []) diff --git a/sanic/compat.py b/sanic/compat.py index 30aec0a7..6ca7e344 100644 --- a/sanic/compat.py +++ b/sanic/compat.py @@ -2,6 +2,5 @@ from multidict import CIMultiDict class Header(CIMultiDict): - - def get_all(self, key): - return self.getall(key, []) + def get_all(self, key): + return self.getall(key, default=[]) diff --git a/sanic/response.py b/sanic/response.py index 34f59e66..6f937c95 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -4,8 +4,8 @@ from os import path from urllib.parse import quote_plus from aiofiles import open as open_async -from multidict import CIMultiDict +from sanic.compat import Header from sanic.cookies import CookieJar from sanic.helpers import STATUS_CODES, has_message_body, remove_entity_headers @@ -74,7 +74,7 @@ class StreamingHTTPResponse(BaseHTTPResponse): self.content_type = content_type self.streaming_fn = streaming_fn self.status = status - self.headers = CIMultiDict(headers or {}) + self.headers = Header(headers or {}) self.chunked = chunked self._cookies = None @@ -164,7 +164,7 @@ class HTTPResponse(BaseHTTPResponse): self.body = body_bytes self.status = status - self.headers = CIMultiDict(headers or {}) + self.headers = Header(headers or {}) self._cookies = None def output(self, version="1.1", keep_alive=False, keep_alive_timeout=None):