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

Exception with MultiDict in POST request #114

Closed
pepijndevos opened this issue Jul 9, 2014 · 5 comments
Closed

Exception with MultiDict in POST request #114

pepijndevos opened this issue Jul 9, 2014 · 5 comments
Assignees

Comments

@pepijndevos
Copy link

I'm trying to POST mutliple values with the same name with aiohttp, but get the following exception:

Traceback (most recent call last):
  File "bug.py", line 7, in <module>
    loop.run_until_complete(aiohttp.request('POST', "http://httpbin.org/post", data=d))
  File "/usr/lib64/python3.4/asyncio/base_events.py", line 208, in run_until_complete
    return future.result()
  File "/usr/lib64/python3.4/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/lib64/python3.4/asyncio/tasks.py", line 317, in _step
    result = coro.throw(exc)
  File "/home/pepijn/code/eppserver/env/lib/python3.4/site-packages/aiohttp/client.py", line 111, in request
    yield from resp.start(conn, read_until_eof)
  File "/home/pepijn/code/eppserver/env/lib/python3.4/site-packages/aiohttp/client.py", line 604, in start
    self.message = yield from httpstream.read()
  File "/home/pepijn/code/eppserver/env/lib/python3.4/site-packages/aiohttp/streams.py", line 366, in read
    return (yield from super().read())
  File "/home/pepijn/code/eppserver/env/lib/python3.4/site-packages/aiohttp/streams.py", line 341, in read
    yield from self._waiter
  File "/usr/lib64/python3.4/asyncio/futures.py", line 348, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib64/python3.4/asyncio/tasks.py", line 370, in _wakeup
    value = future.result()
  File "/usr/lib64/python3.4/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/home/pepijn/code/eppserver/env/lib/python3.4/site-packages/aiohttp/client.py", line 496, in write_bytes
    request.write(chunk)
  File "/home/pepijn/code/eppserver/env/lib/python3.4/site-packages/aiohttp/protocol.py", line 666, in write
    chunk is EOF_MARKER), chunk
AssertionError: a

Example code:

import asyncio
import aiohttp
from aiohttp.multidict import MultiDict

loop = asyncio.get_event_loop()
d = MultiDict([('a', 'b'), ('a', 'c')])
loop.run_until_complete(aiohttp.request('POST', "http://httpbin.org/post", data=d))
@pepijndevos
Copy link
Author

What's more, GET just ignores any subsequent parameters.

import asyncio
import aiohttp
from aiohttp.multidict import MultiDict

loop = asyncio.get_event_loop()
d = MultiDict([('a', 'b'), ('a', 'c')])
resp = loop.run_until_complete(aiohttp.request('GET', "http://httpbin.org/get", params=d))
json = loop.run_until_complete(resp.json())
print(d, json)

@fafhrd91
Copy link
Member

fafhrd91 commented Jul 9, 2014

did you try to use just list() instead of MultiDict ?

@fafhrd91
Copy link
Member

fixed in master

@pepijndevos
Copy link
Author

Tanks for the fix. When looking for a way to send duplicate params, I found MultiDict and blindly assumed that must be the way.

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants