mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
The new version of requests un-vendors urllib3, with a nifty hack: https://github.com/kennethreitz/requests/blob/master/requests/packages.py Unfortunately messing directly with sys.modules causes some weird behavior that I don't entirely understand. Avoiding the extra import to requests.packages as part of VCR's initialization seems to sidestep the issue. Closes #311
20 lines
688 B
Python
20 lines
688 B
Python
'''Stubs for requests'''
|
|
|
|
try:
|
|
from urllib3.connectionpool import HTTPConnection, VerifiedHTTPSConnection
|
|
except ImportError:
|
|
from requests.packages.urllib3.connectionpool import HTTPConnection, VerifiedHTTPSConnection
|
|
|
|
from ..stubs import VCRHTTPConnection, VCRHTTPSConnection
|
|
|
|
# urllib3 defines its own HTTPConnection classes, which requests goes ahead and assumes
|
|
# you're using. It includes some polyfills for newer features missing in older pythons.
|
|
|
|
|
|
class VCRRequestsHTTPConnection(VCRHTTPConnection, HTTPConnection):
|
|
_baseclass = HTTPConnection
|
|
|
|
|
|
class VCRRequestsHTTPSConnection(VCRHTTPSConnection, VerifiedHTTPSConnection):
|
|
_baseclass = VerifiedHTTPSConnection
|