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

Remove fragment string in request path #846

Closed
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ def update_path(self, params):
query = params

self.path = urllib.parse.urlunsplit(('', '', helpers.requote_uri(path),
query, fragment))
query, ''))
self.url = urllib.parse.urlunsplit(
(scheme, netloc, self.path, '', ''))
(scheme, netloc, self.path, '', fragment))

def update_headers(self, headers):
"""Update request headers."""
Expand Down
14 changes: 12 additions & 2 deletions tests/test_client_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,23 @@ def test_path_safe_chars_preserved(make_request):
def test_params_are_added_before_fragment1(make_request):
req = make_request('GET', "http://example.com/path#fragment",
params={"a": "b"})
assert req.path == "/path?a=b#fragment"
assert req.url == "http://example.com/path?a=b#fragment"


def test_params_are_added_before_fragment2(make_request):
req = make_request('GET', "http://example.com/path?key=value#fragment",
params={"a": "b"})
assert req.path == "/path?key=value&a=b#fragment"
assert req.url == "http://example.com/path?key=value&a=b#fragment"


def test_path_not_contain_fragment1(make_request):
req = make_request('GET', "http://example.com/path#fragment")
assert req.path == "/path"


def test_path_not_contain_fragment2(make_request):
req = make_request('GET', "http://example.com/path?key=value#fragment")
assert req.path == "/path?key=value"


def test_cookies(make_request):
Expand Down