Our documentation doesn't currently cover the byte stream interface.
We should document why we have a byte stream abstraction, and link to it from the Content Types, section.
For example we need to document the .encode() -> [Stream, str] interface for returning the content and content type.
Examples look a bit like this...
>>> r cli.get('https://www.example.com')
>>> print(r.stream)
<ByteStream [100% of 64kB]>
# Response with Content-Length
>>> with cli.stream('GET', 'https://www.example.com') as r:
>>> print(r.stream)
<ByteStream [0% of 64kB]>
# Response with `Transfer-Encoding: chunked`
>>> with cli.stream('GET', 'https://www.example.com') as r
>>> print(r.stream)
<ByteStream [0% of ???]>
# Response with `Transfer-Encoding: chunked`
>>> with cli.stream('GET', 'https://www.example.com') as r
>>> r.read(30*1024)
>>> print(r.stream)
<ByteStream [???% of ???]>
# Response with `Transfer-Encoding: chunked`
>>> with cli.stream('GET', 'https://www.example.com') as r
>>> r.read()
>>> print(r.stream)
<ByteStream [100% of 64kB]>
See related #30 which has an interesting note on HTTPByteStream as a class name. This would also be useful because the stream under-run/overrun in that case could raise a slightly more explicit error than the generic ValueError case.
Our documentation doesn't currently cover the byte stream interface.
We should document why we have a byte stream abstraction, and link to it from the
Content Types, section.For example we need to document the
.encode() -> [Stream, str]interface for returning the content and content type.Examples look a bit like this...
See related #30 which has an interesting note on
HTTPByteStreamas a class name. This would also be useful because the stream under-run/overrun in that case could raise a slightly more explicit error than the genericValueErrorcase.