For aiohttp instrumentation, if response body monitoring is enabled, we were consuming the response for reporting but then the customer was unable to consume it again as the stream was finished. This fix "unreads" the response data, so that customer can reread it.
What Was Happening?
Note that this is a very specific case in which the transient dependency aiobotocore library accesses the internals of aiohttp instead of relying its public read method which we were already using. If aiobotocore also used read, it would successfully read the response many times because that read method caches the response body. However, since aiobotocore accesses the underlying stream directly, once we read the stream for response body reporting, it can't reread it through the underlying stream.
The fix rewinds the underlying stream to its initial position by unreading the data.
Testing done
Unit and integration tested (integration tests for this specific case will be added in a separate PR for the lambda SDK).
Description
What Was Happening?
aiobotocore
library accesses the internals ofaiohttp
instead of relying its publicread
method which we were already using. Ifaiobotocore
also usedread
, it would successfully read the response many times because thatread
method caches the response body. However, sinceaiobotocore
accesses the underlying stream directly, once we read the stream for response body reporting, it can't reread it through the underlying stream.Testing done
Unit and integration tested (integration tests for this specific case will be added in a separate PR for the lambda SDK).