From 2f8a231e1774436a8d6db614da784f762aa8d6e5 Mon Sep 17 00:00:00 2001 From: iceboy Date: Mon, 3 Apr 2017 20:52:50 -0700 Subject: [PATCH] keep blank values while parsing form (#1765) --- CHANGES.rst | 6 ++++++ CONTRIBUTORS.txt | 1 + aiohttp/web_request.py | 1 + tests/test_web_functional.py | 4 ++-- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 183cad920b5..ae22cd3d395 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,12 @@ Changes ======= +2.0.6 (2017-04-xx) +------------------ + +- Keeping blank values for `request.post()` #1765 + + 2.0.5 (2017-03-29) ------------------ diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index c16001c71b1..773c8ebb9ca 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -93,6 +93,7 @@ Kirill Malovitsa Kyrylo Perevozchikov Lars P. Søndergaard Louis-Philippe Huberdeau +Lu Gong Lubomir Gelo Ludovic Gasc Lukasz Marcin Dobrzanski diff --git a/aiohttp/web_request.py b/aiohttp/web_request.py index e82b587574c..9f4ce494976 100644 --- a/aiohttp/web_request.py +++ b/aiohttp/web_request.py @@ -427,6 +427,7 @@ def post(self): out.extend( parse_qsl( data.rstrip().decode(charset), + keep_blank_values=True, encoding=charset)) self._post = MultiDictProxy(out) diff --git a/tests/test_web_functional.py b/tests/test_web_functional.py index 27dd227b66d..053a68c0f14 100644 --- a/tests/test_web_functional.py +++ b/tests/test_web_functional.py @@ -127,14 +127,14 @@ def test_post_form(loop, test_client): @asyncio.coroutine def handler(request): data = yield from request.post() - assert {'a': '1', 'b': '2'} == data + assert {'a': '1', 'b': '2', 'c': ''} == data return web.Response(body=b'OK') app = web.Application() app.router.add_post('/', handler) client = yield from test_client(app) - resp = yield from client.post('/', data={'a': 1, 'b': 2}) + resp = yield from client.post('/', data={'a': 1, 'b': 2, 'c': ''}) assert 200 == resp.status txt = yield from resp.text() assert 'OK' == txt