Description
botocore.StreamingBody
is a wrapper class for urllib3.response.HTTPResponse, which explicitly defines an API that exposes some of the underlying methods and adds additional ones on top. It does not otherwise forward attribute calls to the underlying HTTPResponse
afaict.
aiobotocore.StreamingBody
uses wrapt.ObjectProxy
to wrap aiohttp.ClientResponse
, which means it forwards all underlying methods, and additionally specifies most of the methods that botocore.StreamingBody
does. This means it has a larger API, but one that is tightly tied to aiohttp.ClientResponse
.
The soon-to-be-added aiobotocore.HttpxStreamingbody
is in a tough position. It currently uses wrapt.ObjectProxy
to wrap httpx.Response
, but httpx.Response
differs against both of the former in that it requires you to specify the chunk size up-front, so unless we write a complicated helper method we cannot expose a read
method that takes a parameter to specify the number of bytes to read.
There's also differences in e.g. aiohttp.ClientResponse
exposing a sync close()
method, which httpx.Response
doesn't.
It's all kind of a mess at the moment, and if we want the aiobotocore API of [Httpx]StreamingBody
to be library-agnostic between aiohttp & httpx we'll likely need to stop using wrap.ObjectProxy
and explicitly define the API.
We then have to decide whether to remove functionality, write complicated functions to translate between them, petition httpx to implement more functionality, make it possible to directly access the underlying stream when users do want to opt into library-specific functionality, and/or raise helpful error messages when something breaks because the backend changed.
See #1085 (comment) and #1085 (comment) for previous discussion.