Skip to content

Commit

Permalink
add read to httpclienttransportresponse
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft committed Aug 27, 2021
1 parent 11338f4 commit 7fb1e18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 6 additions & 7 deletions sdk/core/azure-core/azure/core/pipeline/transport/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,7 @@ def __init__(self, **kwargs):
self.headers = _case_insensitive_dict(self._internal_response.getheaders())
self.reason = self._internal_response.reason
self.content_type = self.headers.get("Content-Type")
self._data = None

@property
def content(self):
if self._data is None:
self._data = self._internal_response.read()
return self._data
self._content = None

class RestHttpClientTransportResponse(_RestHttpClientTransportResponse, RestHttpResponse):
"""Create a Rest HTTPResponse from an http.client response.
Expand All @@ -555,6 +549,11 @@ def iter_bytes(self):
def iter_raw(self):
raise TypeError("We do not support iter_raw for this transport response")

def read(self):
if self._content is None:
self._content = self._internal_response.read()
return self._content


class BytesIOSocket(object):
"""Mocking the "makefile" of socket for HTTPResponse.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ async def iter_bytes(self):
async def iter_raw(self):
raise TypeError("We do not support iter_raw for this transport response")

async def read(self):
if self._content is None:
self._content = self._internal_response.read()
return self._content


class AsyncHttpTransport(
AbstractAsyncContextManager,
Expand Down

0 comments on commit 7fb1e18

Please sign in to comment.