Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leave stream open in response #19711

Merged
merged 4 commits into from
Jul 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions tools/vcrpy/vcr/stubs/aiohttp_stubs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, method, url, request_info=None):
loop=asyncio.get_event_loop(),
session=None,
)
self._content = None

async def json(self, *, encoding="utf-8", loads=json.loads, **kwargs): # NOQA: E999
stripped = self._body.strip()
Expand All @@ -51,10 +52,11 @@ def release(self):

@property
def content(self):
s = MockStream()
s.feed_data(self._body)
s.feed_eof()
return s
if not self._content:
self._content = MockStream()
self._content.feed_data(self._body)
self._content.feed_eof()
return self._content


def build_response(vcr_request, vcr_response, history):
Expand All @@ -71,7 +73,6 @@ def build_response(vcr_request, vcr_response, history):
response._headers = CIMultiDictProxy(CIMultiDict(vcr_response["headers"]))
response._history = tuple(history)

response.close()
return response


Expand Down