diff --git a/aiorest/handler.py b/aiorest/handler.py index c5f4c55..23a88c9 100644 --- a/aiorest/handler.py +++ b/aiorest/handler.py @@ -77,7 +77,7 @@ def handle_request(self, message, payload): else: resp_impl.add_header('Content-Length', str(len(bbody))) - headers = request.response.headers.items(getall=True) + headers = request.response.headers.items() for key, val in headers: resp_impl.add_header(key, val) diff --git a/aiorest/request.py b/aiorest/request.py index 917c8a8..f01a406 100644 --- a/aiorest/request.py +++ b/aiorest/request.py @@ -4,7 +4,7 @@ from urllib.parse import urlsplit, parse_qsl -from aiohttp.multidict import MultiDict, MutableMultiDict +from aiohttp.multidict import MultiDict, CIMultiDict, MultiDictProxy from .errors import JsonLoadError, JsonDecodeError @@ -18,7 +18,7 @@ class Response: def __init__(self): - self.headers = MutableMultiDict() + self.headers = CIMultiDict() self._status_code = 200 self._cookies = http.cookies.SimpleCookie() self._deleted_cookies = set() @@ -99,7 +99,7 @@ def __init__(self, host, message, req_body, *, self.path_url = self.host_url + self.path self.url = self.host_url + self.path_qs self.query_string = res.query - self.args = MultiDict(parse_qsl(res.query)) + self.args = MultiDictProxy(MultiDict(parse_qsl(res.query))) self.headers = message.headers self.matchdict = {} self._request_body = req_body @@ -159,8 +159,9 @@ def cookies(self): if self._cookies is None: raw = self.headers.get('COOKIE', '') parsed = http.cookies.SimpleCookie(raw) - self._cookies = MultiDict({key: val.value - for key, val in parsed.items()}) + self._cookies = MultiDictProxy(MultiDict({key: val.value + for key, val in + parsed.items()})) return self._cookies def add_response_callback(self, callback, *args, **kwargs): diff --git a/tests/cookies_test.py b/tests/cookies_test.py index 0f41f61..fd3a81b 100644 --- a/tests/cookies_test.py +++ b/tests/cookies_test.py @@ -5,7 +5,7 @@ from unittest import mock from aiorest import Request, Response -from aiohttp.multidict import MutableMultiDict, CaseInsensitiveMultiDict +from aiohttp import MultiDict, CIMultiDict class CookiesTests(unittest.TestCase): @@ -13,11 +13,11 @@ class CookiesTests(unittest.TestCase): def setUp(self): self.loop = mock.Mock() self._REQUEST = aiohttp.RawRequestMessage( - 'GET', '/some/path', '1.1', MutableMultiDict(), True, None) + 'GET', '/some/path', '1.1', MultiDict(), True, None) def test_no_request_cookies(self): req = Request('host', aiohttp.RawRequestMessage( - 'GET', '/some/path', '1.1', CaseInsensitiveMultiDict(), + 'GET', '/some/path', '1.1', CIMultiDict(), True, None), None, loop=self.loop)