Streaming¶
The bareUtils module bareutils.streaming provides constants and helper
functions for streaming body content.
More information can be found in the api.
Body content is sent and received as asynchronous iterators.
The most common functions are:
bytes_readerto read streams of bytes,bytes_writerto write streams of bytes,text_readerto read streams of text,text_writerto write streams of text.
For example to read a text stream from a request handler:
from bareasgi import HttpRequest, HttpResponse
from bareutils import text_reader
async def handle_request(request: HttpRequest) -> HttpResponse:
text = await text_reader(content)
return HttpResponse(200, [(b'content-type', b'text/plain')], text_write(text.lower()))