diff --git a/src/microdot/microdot.py b/src/microdot/microdot.py index eb1d8d0..870ef11 100644 --- a/src/microdot/microdot.py +++ b/src/microdot/microdot.py @@ -366,8 +366,8 @@ class Request: self.content_type = self.headers['Content-Type'] if 'Cookie' in self.headers: for cookie in self.headers['Cookie'].split(';'): - name, value = cookie.strip().split('=', 1) - self.cookies[name] = value + c = cookie.strip().split('=', 1) + self.cookies[c[0]] = c[1] if len(c) > 1 else '' self._body = body self.body_used = False diff --git a/tests/test_request.py b/tests/test_request.py index f9a7b59..d4e2b7e 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -35,16 +35,17 @@ class TestRequest(unittest.TestCase): def test_headers(self): fd = get_async_request_fd('GET', '/foo', headers={ 'Content-Type': 'application/json', - 'Cookie': 'foo=bar;abc=def', + 'Cookie': 'foo=bar;nothing;abc=def;', 'Content-Length': '3'}, body='aaa') req = self._run(Request.create('app', fd, 'writer', 'addr')) self.assertEqual(req.headers, { 'Host': 'example.com:1234', 'Content-Type': 'application/json', - 'Cookie': 'foo=bar;abc=def', + 'Cookie': 'foo=bar;nothing;abc=def;', 'Content-Length': '3'}) self.assertEqual(req.content_type, 'application/json') - self.assertEqual(req.cookies, {'foo': 'bar', 'abc': 'def'}) + self.assertEqual(req.cookies, {'foo': 'bar', 'nothing': '', + 'abc': 'def', '': ''}) self.assertEqual(req.content_length, 3) self.assertEqual(req.body, b'aaa')