Skip to content

Commit

Permalink
Merge pull request #853 from mickael9/mickael9-patch-1
Browse files Browse the repository at this point in the history
Drop initial query parameters on redirects
  • Loading branch information
asvetlov committed Apr 26, 2016
2 parents 7dac70f + f75b33b commit 63cf125
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 63cf125

Please sign in to comment.