mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-11 18:06:10 +00:00
Respect urllib3.response.HTTPResponse.data
This commit is contained in:
@@ -249,12 +249,13 @@ class VCRConnection:
|
|||||||
|
|
||||||
# get the response
|
# get the response
|
||||||
response = self.real_connection.getresponse()
|
response = self.real_connection.getresponse()
|
||||||
|
response_data = response.data if hasattr(response, "data") else response.read()
|
||||||
|
|
||||||
# put the response into the cassette
|
# put the response into the cassette
|
||||||
response = {
|
response = {
|
||||||
"status": {"code": response.status, "message": response.reason},
|
"status": {"code": response.status, "message": response.reason},
|
||||||
"headers": serialize_headers(response),
|
"headers": serialize_headers(response),
|
||||||
"body": {"string": response.read()},
|
"body": {"string": response_data},
|
||||||
}
|
}
|
||||||
self.cassette.append(self._vcr_request, response)
|
self.cassette.append(self._vcr_request, response)
|
||||||
return VCRHTTPResponse(response)
|
return VCRHTTPResponse(response)
|
||||||
|
|||||||
Reference in New Issue
Block a user