mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
Make VCRHTTPResponse interface satisfy urllib3.response.HTTPResponse
This commit is contained in:
committed by
Kevin McCarthy
parent
fd1aaab3bf
commit
1b3a1235f2
@@ -144,6 +144,28 @@ class VCRHTTPResponse(HTTPResponse):
|
||||
def readable(self):
|
||||
return self._content.readable()
|
||||
|
||||
@property
|
||||
def length_remaining(self):
|
||||
return self._content.getbuffer().nbytes - self._content.tell()
|
||||
|
||||
def get_redirect_location(self):
|
||||
"""
|
||||
Returns (a) redirect location string if we got a redirect
|
||||
status code and valid location, (b) None if redirect status and
|
||||
no location, (c) False if not a redirect status code.
|
||||
See https://urllib3.readthedocs.io/en/stable/reference/urllib3.response.html .
|
||||
"""
|
||||
if not (300 <= self.status <= 399):
|
||||
return False
|
||||
return self.getheader("Location")
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
return self._content.getbuffer().tobytes()
|
||||
|
||||
def drain_conn(self):
|
||||
pass
|
||||
|
||||
|
||||
class VCRConnection:
|
||||
# A reference to the cassette that's currently being patched in
|
||||
|
||||
Reference in New Issue
Block a user