1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 09:13:23 +00:00

fix sync do_request().stream

This commit is contained in:
Thomas Grainger
2023-12-15 13:40:06 +00:00
parent cf765928ac
commit 356ff4122c

View File

@@ -51,8 +51,14 @@ class DoSyncRequest(BaseDoRequest):
return self.client.request(*args, timeout=60, **kwargs)
def stream(self, *args, **kwargs):
with self.client.stream(*args, **kwargs) as response:
return b"".join(response.iter_bytes())
if hasattr(self, "_client"):
with self.client.stream(*args, **kwargs) as response:
return b"".join(response.iter_bytes())
# Use one-time context and dispose of the client afterwards
with self:
with self.client.stream(*args, **kwargs) as response:
return b"".join(response.iter_bytes())
class DoAsyncRequest(BaseDoRequest):