Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop initial query parameters on redirects #853

Merged
merged 1 commit into from
Apr 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
@@ -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

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

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