Closed elupus closed 7 years ago
There is no such standard, libraries use different encoding schema. That's why I doubt if yarl/aiohttp should support it: if we choose one convention people will blame us that another convention is not used etc.
I will close this as partly invalid. I had missed the support for MultiDict parameters. They work perfectly fine for passing this data.
My code snippet to overcome this issue (in class inherited from ClientSession)
async def _request(self, *args, **kwargs):
params = kwargs.pop('params', None)
if params:
new_params = MultiDict()
if isinstance(params, Mapping):
for k, v in params.items():
if isinstance(v, (list, tuple)):
for value in v:
new_params.add(k, value)
else:
new_params.extend({k: v})
else:
new_params = params
kwargs['params'] = new_params
...
(moving from requests from aiohttp, a lot of places uses this feature http://docs.python-requests.org/en/master/user/quickstart/#passing-parameters-in-urls bottom part)
Feature itself I think goes from usage of urllib.urlencode
with doseq=True
Inheritance from ClientSession
is deprecated and will be strictly forbidden in future aiohttp releases.
Long story short
Making a request according to application/x-www-form-urlencoded for a list of values is not supported using normal params parameter. For example with a parameter string of: {'select' : [1, 2, 3]}
Can't find any good reference to a standard (closest i got was https://stackoverflow.com/questions/2602043/rest-api-best-practice-how-to-accept-list-of-parameter-values-as-input).
Expected behaviour
Resulting query like
"?select[]=1&select[]=2&select[]=3"
or without the []"?select=1&select=2&select=3"
Actual behaviour
Steps to reproduce
Your environment
Windows 10 aiohttp=2.2.5 yarl=0.13.0