mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-10 01:25:34 +00:00
Fix Requests so it can gunzip the request body
I wasn't emulating the stateful file-object in my response stub, so urllib3 wasn't decompressing gzipped bodies properly. This should fix that problem. Thanks @bryanhelmig for the motivation to dig into this.
This commit is contained in:
@@ -16,6 +16,7 @@ class VCRHTTPResponse(object):
|
||||
self.status = recorded_response['status']['code']
|
||||
self.version = None
|
||||
self._content = StringIO(self.recorded_response['body']['string'])
|
||||
self.closed = False
|
||||
|
||||
# We are skipping the header parsing (they have already been parsed
|
||||
# at this point) and directly adding the headers to the header
|
||||
@@ -37,12 +38,13 @@ class VCRHTTPResponse(object):
|
||||
return self._content.read(*args, **kwargs)
|
||||
|
||||
def close(self):
|
||||
self.closed = True
|
||||
return True
|
||||
|
||||
def isclosed(self):
|
||||
# Urllib3 seems to call this because it actually uses
|
||||
# the weird chunking support in httplib
|
||||
return True
|
||||
return self.closed
|
||||
|
||||
def getheaders(self):
|
||||
return self.recorded_response['headers'].iteritems()
|
||||
|
||||
Reference in New Issue
Block a user