]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
dont try to load chunked responses from cassettes, we already unchunked everything
authorKevin McCarthy <me@kevinmccarthy.org>
Wed, 6 May 2015 07:32:32 +0000 (21:32 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Wed, 6 May 2015 07:32:32 +0000 (21:32 -1000)
vcr/stubs/__init__.py

index e45e65846222adc73ebd69bd966c747120ec629f..c094e569bb3151e73f0eb538c71404c82b13e814 100644 (file)
@@ -76,6 +76,13 @@ class VCRHTTPResponse(HTTPResponse):
         self._closed = False
 
         headers = self.recorded_response['headers']
+        # Since we are loading a response that has already been serialized, our
+        # response is no longer chunked.  That means we don't want any
+        # libraries trying to process a chunked response.  By removing the
+        # transfer-encoding: chunked header, this should cause the downstream
+        # libraries to process this as a non-chunked response.
+        if 'chunked' in headers.get('transfer-encoding', []):
+            del headers['transfer-encoding']
         self.headers = self.msg = parse_headers(headers)
 
         self.length = compat.get_header(self.msg, 'content-length') or None