Skip to content
Merged
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
Fix #141: don't append data to path for GET request
  • Loading branch information
asvetlov committed Aug 28, 2014
commit da583fbd4eb2eec1e8e65a3fd521e1518b130bae
10 changes: 2 additions & 8 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def __init__(self, method, url, *,

self.update_version(version)
self.update_host(url)
self.update_path(params, data)
self.update_path(params)
self.update_headers(headers)
self.update_cookies(cookies)
self.update_content_encoding()
Expand Down Expand Up @@ -264,7 +264,7 @@ def update_version(self, version):
.format(version)) from None
self.version = version

def update_path(self, params, data):
def update_path(self, params):
"""Build path."""
# extract path
scheme, netloc, path, query, fragment = urllib.parse.urlsplit(self.url)
Expand All @@ -276,12 +276,6 @@ def update_path(self, params, data):
elif isinstance(params, MultiDict):
params = list(params.items(getall=True))

# for GET request include data to query params
if data and self.method in self.GET_METHODS:
if isinstance(data, dict):
data = data.items()
params = list(itertools.chain(params or (), data))

if params:
params = urllib.parse.urlencode(params)
if query:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,8 @@ def test_get_with_data(self):
for meth in ClientRequest.GET_METHODS:
req = ClientRequest(
meth, 'http://python.org/', data={'life': '42'})
self.assertEqual('/?life=42', req.path)
self.assertEqual('/', req.path)
self.assertEqual(b'life=42', req.body)

def test_bytes_data(self):
for meth in ClientRequest.POST_METHODS:
Expand Down