1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 01:03:24 +00:00

Merge pull request #14 from vitormazzi/master

Updates to work with requests 1.2.3 and bump version.

Closes #13, #12
This commit is contained in:
Kevin McCarthy
2013-07-20 02:04:31 -07:00
3 changed files with 11 additions and 4 deletions

View File

@@ -19,7 +19,7 @@ class PyTest(TestCommand):
sys.exit(errno)
setup(name='vcrpy',
version='0.0.2',
version='0.0.3',
description="A Python port of Ruby's VCR to make mocking HTTP easier",
author='Kevin McCarthy',
author_email='me@kevinmccarthy.org',

View File

@@ -8,7 +8,8 @@ _HTTPSConnection = httplib.HTTPSConnection
try:
import requests.packages.urllib3.connectionpool
_VerifiedHTTPSConnection = requests.packages.urllib3.connectionpool.VerifiedHTTPSConnection
_VerifiedHTTPSConnection = requests.packages.urllib3.connectionpool.VerifiedHTTPSConnection
_HTTPConnection = requests.packages.urllib3.connectionpool.HTTPConnection
except ImportError:
pass
@@ -31,6 +32,8 @@ def install(cassette_path):
from .requests_stubs import VCRVerifiedHTTPSConnection
requests.packages.urllib3.connectionpool.VerifiedHTTPSConnection = VCRVerifiedHTTPSConnection
requests.packages.urllib3.connectionpool.VerifiedHTTPSConnection._vcr_cassette_path = cassette_path
requests.packages.urllib3.connectionpool.HTTPConnection = VCRHTTPConnection
requests.packages.urllib3.connectionpool.HTTPConnection._vcr_cassette_path = cassette_path
except ImportError:
pass
@@ -53,6 +56,7 @@ def reset():
try:
import requests.packages.urllib3.connectionpool
requests.packages.urllib3.connectionpool.VerifiedHTTPSConnection = _VerifiedHTTPSConnection
requests.packages.urllib3.connectionpool.HTTPConnection = _HTTPConnection
except ImportError:
pass

View File

@@ -21,10 +21,13 @@ class VCRHTTPResponse(object):
self.length = self.msg.getheader('content-length') or None
def read(self, chunked=False):
def read(self, *args, **kwargs):
# Note: I'm pretty much ignoring any chunking stuff because
# I don't really understand what it is or how it works.
return self._content.read()
return self._content.read(*args, **kwargs)
def close(self):
return True
def isclosed(self):
# Urllib3 seems to call this because it actually uses