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

Conform to RFC3986 - do not include url fragments in requests #1174

Merged
merged 2 commits into from
Sep 15, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Expand Up @@ -181,6 +181,7 @@ def _request(self, method, url, *,
skip_headers.add(istr(i))

while True:
url, _ = urllib.parse.urldefrag(url)

cookies = self._cookie_jar.filter_cookies(url)

Expand Down
39 changes: 39 additions & 0 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,45 @@ def handler_ok(request):
yield from resp.release()


@asyncio.coroutine
def test_drop_fragment_on_redirect(create_app_and_client):
@asyncio.coroutine
def handler_redirect(request):
return web.Response(status=301, headers={'Location': '/ok#fragment'})

@asyncio.coroutine
def handler_ok(request):
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')
try:
assert resp.status == 200
assert resp.url.endswith('/ok')
finally:
yield from resp.release()


@asyncio.coroutine
def test_drop_fragment(create_app_and_client):
@asyncio.coroutine
def handler_ok(request):
return web.Response(status=200)

app, client = yield from create_app_and_client()
app.router.add_route('GET', '/ok', handler_ok)

resp = yield from client.get('/ok#fragment')
try:
assert resp.status == 200
assert resp.url.endswith('/ok')
finally:
yield from resp.release()


@asyncio.coroutine
def test_history(create_app_and_client):
@asyncio.coroutine
Expand Down