<commit_before>"""Intercept HTTP connections that use `requests <http://docs.python-requests.org/en/latest/>`_.
"""

from . import WSGI_HTTPConnection, WSGI_HTTPSConnection, wsgi_fake_socket
from requests.packages.urllib3.connectionpool import (HTTPConnectionPool,
        HTTPSConnectionPool)
from requests.packages.urllib3.connection import (HTTPConnection,
        HTTPSConnection)


wsgi_fake_socket.settimeout = lambda self, timeout: None


class HTTP_WSGIInterceptor(WSGI_HTTPConnection, HTTPConnection):
    pass


class HTTPS_WSGIInterceptor(WSGI_HTTPSConnection, HTTPSConnection):
    pass


def install():
    HTTPConnectionPool.ConnectionCls = HTTP_WSGIInterceptor
    HTTPSConnectionPool.ConnectionCls = HTTPS_WSGIInterceptor


def uninstall():
    HTTPConnectionPool.ConnectionCls = HTTPConnection
    HTTPSConnectionPool.ConnectionCls = HTTPSConnection<commit_msg>Deal with request's urllib3 being annoying about 'strict'<commit_after>"""Intercept HTTP connections that use `requests <http://docs.python-requests.org/en/latest/>`_.
"""

import sys

from . import WSGI_HTTPConnection, WSGI_HTTPSConnection, wsgi_fake_socket
from requests.packages.urllib3.connectionpool import (HTTPConnectionPool,
        HTTPSConnectionPool)
from requests.packages.urllib3.connection import (HTTPConnection,
        HTTPSConnection)


wsgi_fake_socket.settimeout = lambda self, timeout: None


class HTTP_WSGIInterceptor(WSGI_HTTPConnection, HTTPConnection):
    def __init__(self, *args, **kwargs):
        if 'strict' in kwargs and sys.version_info > (3, 0):
            kwargs.pop('strict')
        WSGI_HTTPConnection.__init__(self, *args, **kwargs)
        HTTPConnection.__init__(self, *args, **kwargs)


class HTTPS_WSGIInterceptor(WSGI_HTTPSConnection, HTTPSConnection):
    def __init__(self, *args, **kwargs):
        if 'strict' in kwargs and sys.version_info > (3, 0):
            kwargs.pop('strict')
        WSGI_HTTPSConnection.__init__(self, *args, **kwargs)
        HTTPSConnection.__init__(self, *args, **kwargs)


def install():
    HTTPConnectionPool.ConnectionCls = HTTP_WSGIInterceptor
    HTTPSConnectionPool.ConnectionCls = HTTPS_WSGIInterceptor


def uninstall():
    HTTPConnectionPool.ConnectionCls = HTTPConnection
    HTTPSConnectionPool.ConnectionCls = HTTPSConnection
{'fraction_non_alphanumeric': 0.08928571428571429, 'fraction_numerical': 0.0039198606271777, 'mean_word_length': 5.060686015831134, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5308377', 'n_tokens_mistral': 678, 'n_tokens_neox': 656, 'n_words': 138}