From 3411bedc0665beef5bd2dc31061bb88beaa0eb60 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Tue, 20 Jun 2023 23:49:57 +0200 Subject: [PATCH] Make response.raw.stream() work for urllib3 v2 --- vcr/stubs/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vcr/stubs/__init__.py b/vcr/stubs/__init__.py index 7c7dbe0..2a34ea1 100644 --- a/vcr/stubs/__init__.py +++ b/vcr/stubs/__init__.py @@ -170,6 +170,13 @@ class VCRHTTPResponse(HTTPResponse): def drain_conn(self): pass + def stream(self, amt=65536, decode_content=None): + while True: + b = self._content.read(amt) + yield b + if not b: + break + class VCRConnection: # A reference to the cassette that's currently being patched in