From 6208b0ce61a9fdfc287b480c3d8375d51a6f993b Mon Sep 17 00:00:00 2001 From: Bryan Helmig Date: Sun, 28 Apr 2013 12:12:22 -0700 Subject: [PATCH 1/4] patch plain HTTP for requests --- vcr/patch.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcr/patch.py b/vcr/patch.py index f5b82cb..95c5c49 100644 --- a/vcr/patch.py +++ b/vcr/patch.py @@ -31,6 +31,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 From 74941f68c60255074abae29d66f5019b2aa47ffb Mon Sep 17 00:00:00 2001 From: Bryan Helmig Date: Sun, 28 Apr 2013 12:40:07 -0700 Subject: [PATCH 2/4] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 954bece..97a831a 100644 --- a/setup.py +++ b/setup.py @@ -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', From 41fd8411cf6dfac1a0d1524b34689c3e3bc1fbda Mon Sep 17 00:00:00 2001 From: "Vitor M. A. da Cruz" Date: Fri, 21 Jun 2013 16:54:24 -0300 Subject: [PATCH 3/4] Update stubs.py `VCRHTTPResponse.close` method must be defined for urllib3. `VCRHTTPResponse.read` does not need to care about the paremeters passed to it --- vcr/stubs.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vcr/stubs.py b/vcr/stubs.py index 91ed0e2..898e350 100644 --- a/vcr/stubs.py +++ b/vcr/stubs.py @@ -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 From 8701e6025b28739b6f87efdd0ebad668260adde0 Mon Sep 17 00:00:00 2001 From: "Vitor M. A. da Cruz" Date: Fri, 5 Jul 2013 16:48:30 -0300 Subject: [PATCH 4/4] Removing patch for plain http using requests during reset The patch was not removed, so subsequent connections were affected --- vcr/patch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vcr/patch.py b/vcr/patch.py index 95c5c49..82bc3d8 100644 --- a/vcr/patch.py +++ b/vcr/patch.py @@ -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 @@ -55,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