Skip to content

Commit

Permalink
Dirty fix for aiohttp 0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jan 18, 2015
1 parent 05199ac commit cba79a2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion aiorest/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 6 additions & 5 deletions aiorest/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tests/cookies_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
from unittest import mock

from aiorest import Request, Response
from aiohttp.multidict import MutableMultiDict, CaseInsensitiveMultiDict
from aiohttp import MultiDict, CIMultiDict


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)

Expand Down

0 comments on commit cba79a2

Please sign in to comment.