Skip to content

Commit

Permalink
Drop initial query parameters on redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael9 committed Apr 25, 2016
1 parent 7dac70f commit f75b33b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
22 changes: 22 additions & 0 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f75b33b

Please sign in to comment.