Skip to content

Commit

Permalink
add set_read_checks
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft committed Aug 30, 2021
1 parent 0a1eb95 commit 0304a0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sdk/core/azure-core/azure/core/_pipeline_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ async def _make_pipeline_call(self, request, **kwargs):
# the body is loaded. instead of doing response.read(), going to set the body
# to the internal content
rest_response._content = response.body() # pylint: disable=protected-access
await rest_response.read()
await rest_response._set_read_checks() # pylint: disable=protected-access
await rest_response.close()
except Exception as exc:
await rest_response.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class AsyncHttpResponseImpl(_HttpResponseBaseImpl, _AsyncHttpResponse):
:keyword Callable stream_download_generator: The stream download generator that we use to stream the response.
"""

async def _set_read_checks(self):
self._is_stream_consumed = True
await self.close()

async def read(self) -> bytes:
"""Read the response's bytes into memory.
Expand All @@ -57,7 +61,7 @@ async def read(self) -> bytes:
async for part in self.iter_bytes():
parts.append(part)
self._content = b"".join(parts)
self._is_stream_consumed = True
await self._set_read_checks()
return self._content

async def iter_raw(self) -> AsyncIterator[bytes]:
Expand Down

0 comments on commit 0304a0c

Please sign in to comment.