diff --git a/aiohttp/client.py b/aiohttp/client.py index b583007fe23..e5478df1990 100644 --- a/aiohttp/client.py +++ b/aiohttp/client.py @@ -234,6 +234,7 @@ def _request(self, method, url, *, r_url = urllib.parse.urljoin(url, r_url) url = r_url + params = None yield from resp.release() continue diff --git a/docs/client_reference.rst b/docs/client_reference.rst index c8294ef373a..d67cf4fa2e0 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -133,7 +133,8 @@ The client session supports context manager protocol for self closing. :param params: Mapping, iterable of tuple of *key*/*value* pairs or string to be sent as parameters in the query - string of the new request (optional) + string of the new request. Ignored for subsequent + redirected requests (optional) Allowed values are: diff --git a/tests/test_client_functional.py b/tests/test_client_functional.py index 8b2cda22c4d..b99bd661682 100644 --- a/tests/test_client_functional.py +++ b/tests/test_client_functional.py @@ -338,6 +338,28 @@ def handler(request): yield from resp.release() +@pytest.mark.run_loop +def test_drop_params_on_redirect(create_app_and_client): + @asyncio.coroutine + def handler_redirect(request): + return web.Response(status=301, headers={'Location': '/ok?a=redirect'}) + + @asyncio.coroutine + def handler_ok(request): + assert request.query_string == 'a=redirect' + return web.Response(status=200) + + app, client = yield from create_app_and_client() + app.router.add_route('GET', '/ok', handler_ok) + app.router.add_route('GET', '/redirect', handler_redirect) + + resp = yield from client.get('/redirect', params={'a': 'initial'}) + try: + assert resp.status == 200 + finally: + yield from resp.release() + + @pytest.mark.run_loop def test_history(create_app_and_client): @asyncio.coroutine