Commit a130025d authored by Denis Bilenko's avatar Denis Bilenko

fix Issue 71: gevent.httplib doesn't support HTTPSConnection. Patch by snb at spotify.

parent 2559aceb
# Copyright (C) 2010-2011 gevent contributors. See LICENSE for details. # Copyright (C) 2010-2011 gevent contributors. See LICENSE for details.
__httplib__ = __import__('httplib')
# Get the standard Python httplib as __httplib__, ensuring we get a version
# that hasn't already been modified by monkey patching of any of its members.
# HTTPSConnection must use the standard HTTPConnection because libevent-http
# does not currently support https.
import imp
__httplib__ = imp.load_module('__httplib__', *imp.find_module('httplib'))
from gevent import core from gevent import core
from gevent.hub import Waiter, get_hub from gevent.hub import Waiter, get_hub
...@@ -10,6 +16,7 @@ __implements__ = [ ...@@ -10,6 +16,7 @@ __implements__ = [
] ]
__imports__ = [ __imports__ = [
'HTTPSConnection',
'HTTPException', 'HTTPException',
'InvalidURL', 'InvalidURL',
] ]
...@@ -19,6 +26,7 @@ __all__ = __implements__ + __imports__ ...@@ -19,6 +26,7 @@ __all__ = __implements__ + __imports__
InvalidURL = __httplib__.InvalidURL InvalidURL = __httplib__.InvalidURL
HTTP_PORT = __httplib__.HTTP_PORT HTTP_PORT = __httplib__.HTTP_PORT
HTTPException = __httplib__.HTTPException HTTPException = __httplib__.HTTPException
HTTPSConnection = __httplib__.HTTPSConnection
EV_METHOD_TYPES = dict((name, id) for (id, name) in core.HTTP_method2name.items()) EV_METHOD_TYPES = dict((name, id) for (id, name) in core.HTTP_method2name.items())
......
...@@ -180,9 +180,10 @@ def patch_select(aggressive=False): ...@@ -180,9 +180,10 @@ def patch_select(aggressive=False):
def patch_httplib(): def patch_httplib():
from gevent.httplib import HTTPConnection
httplib = __import__('httplib') httplib = __import__('httplib')
from gevent.httplib import HTTPConnection, HTTPSConnection
httplib.HTTPConnection = HTTPConnection httplib.HTTPConnection = HTTPConnection
httplib.HTTPSConnection = HTTPSConnection
def patch_all(socket=True, dns=True, time=True, select=True, thread=True, os=True, ssl=True, httplib=False, aggressive=True): def patch_all(socket=True, dns=True, time=True, select=True, thread=True, os=True, ssl=True, httplib=False, aggressive=True):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment