This commit will make it possible to add headers to a Websocket.
Among other things, this allows making a connection to online MQTT brokers
over websocket, using the header entry "Sec-WebSocket-Protocol":"mqtt" in
the handshake of the upgrade protocol.
Signed-off-by: Damien George <damien@micropython.org>
According to RFC https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
header names are case-insensitive.
This commit makes sure that the module behaves consistently regardless of
the casing of "Content-type" and "Content-Length" (other headers are not
considered by the module).
Without this fix, the client seems to wait for the connection termination
(~10 seconds) prior to returning any content if the casing of
"Content-Length" is different.
Signed-off-by: FuNK3Y <fun__key@hotmail.com>
The function `binascii.b2a_base64()` returns a `bytes`, but here needs a
string. Otherwise, the value of `Sec-WebSocket-Key` in the headers will be
`b'<BASE64-ENCODED_RANDOM_VALUE>'`.
Signed-off-by: AuroraTea <1352685369@qq.com>
- 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>
Implement `aiohttp` with `ClientSession`, websockets and `SSLContext`
support.
Only client is implemented and API is mostly compatible with CPython
`aiohttp`.
Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>