micropython-lib/python-ecosys/aiohttp
Carlosgg 56f514f569 aiohttp: Fix binary data treatment.
- Fix binary data `Content-type` header and data `Content-Length`
  calculation.

- Fix query length when data is included.

- Fix `json` and `text` methods of `ClientResponse` to read
  `Content-Length` size

Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
2024-02-08 19:02:26 +11:00
..
aiohttp aiohttp: Fix binary data treatment. 2024-02-08 19:02:26 +11:00
examples aiohttp: Add new aiohttp package. 2023-12-20 16:26:04 +11:00
README.md aiohttp: Add new aiohttp package. 2023-12-20 16:26:04 +11:00
manifest.py aiohttp: Fix binary data treatment. 2024-02-08 19:02:26 +11:00

README.md

aiohttp is an HTTP client module for MicroPython asyncio module, with API mostly compatible with CPython aiohttp module.

[!NOTE] Only client is implemented.

See examples/client.py

import aiohttp
import asyncio

async def main():

    async with aiohttp.ClientSession() as session:
        async with session.get('http://micropython.org') as response:

            print("Status:", response.status)
            print("Content-Type:", response.headers['Content-Type'])

            html = await response.text()
            print("Body:", html[:15], "...")

asyncio.run(main())
$ micropython examples/client.py
Status: 200
Content-Type: text/html; charset=utf-8
Body: <!DOCTYPE html> ...