https://github.com/aio-libs The set of asyncio-based libraries built with high quality
popravich on travis_pypy
.travis.yml: chaching pip packa… Makefile: build/install only re… .travis.yml: cache redis-server… (compare)
Hi, I was making a custom MultiPart form-data request and got a 502 (it's either nginx or Apache, so standard).
Commenting out this line was what made the request successful:
https://github.com/aio-libs/aiohttp/blob/5f0a59fd38f048ee65b6199a26d2355075d0d196/aiohttp/helpers.py#L372
Is this covered by some standard?
helpers.content_disposition_header
whether to encode the field value or not. In my case, it was an ASCII string. Also, curl
didn't encode it.
wraptile
posted an image: wraptile
the docs here are incorrect as dict is invalid type
wraptile
ValueError: dictionary update sequence element #0 has length 9; 2 is required
wraptile
what's the de facto way to serialize/deserialize session? For cookies it seems to be awfully complicated
wraptile
```
async def test_cookies():
async with ClientSession() as session:
session.cookie_jar.update_cookies(SimpleCookie('login=jogn; Path=/; Domain=httpbin.org'))
session.cookie_jar.update_cookies(SimpleCookie('pass=snow; Path=/; Domain=httpbin.org'))
session.cookie_jar.update_cookies(SimpleCookie('foo=bar; Path=/;'))
cookies = pickle.dumps(session.cookie_jar._cookies)
resp = await session.get('http://httpbin.org/cookies')
print(await resp.text())
async with ClientSession() as session:
session.cookie_jar._cookies = pickle.loads(cookies)
print(await resp.text())
```
wraptile
this is kinda ugly, but I guess it should work fine? 😬
wraptile
I see the bridge doesn't format the code snippet well either, ugh. Maybe now that Matrix bought gitter they can finally fix this
wraptile
yeah, the code snippet is absed of save() and load()
wraptile
except to memory rather than file
wraptile
I'm kinda disappointed that none of python's http libs implement session serialization/deserialization :|
wraptile
would be great if the API supported ClientSession().dump()
and ClientSession.load(pickle_obj)
or something like that.
And yea, that would be good, re the API for in-memory. I also wish it used something more portable like JSON or CBOR instead of pickle.
I wish I had a better recommendation for you, but based on what’s officially available, the only other thing I can think of is if you don’t actually need session-based cookie management, you can store cookies however you want and send down a dict of your own with the cookies=
arg to individual requests.
Hello, I have odd issue with typing in aiohttp 3.6.2 (latest). I have this piece of code:
import aiohttp
with aiohttp.MultipartWriter('form-data') as mpwriter:
mpwriter.append_json(
{'a': 5},
headers={'content-disposition': 'form-data;name=value_of_a'})
and I have these versions
# python 3.9.0
# aiohttp 3.6.2
# mypy 0.782
and I am getting this error from mypy
:
append.py:6: error: Argument "headers" to "append_json" of "MultipartWriter" has inco
mpatible type "Dict[str, str]"; expected "Optional[MultiMapping[str]]"
Found 1 error in 1 file (checked 1 source file)
Looking at the code of aiohttp, and the documentation examples, I see a mismatch in typing. The documentation uses regular python dict
, while the typing in the implementation expects a multidict
. I would be ok with passing a multidict
instead of dict
, but I don't have this dependency and I don't want to add another dependency to my project because of this. Is the documentation wrong or the implementation wrong? Or am I wrong? Thanks!
asyncio.as_completed
if anyone wants to chime in: python/cpython#22491 for bpo-33533
quote_fields
of aiohttp.FormData()
is not documented. The default escaping behavior makes it troublesome to work with array field (e.g., client_files[0]
) since the bracket is escaped. Do you think we should highlight the usage of quote_fields
?