mirror of
https://github.com/kennethreitz/requests3.git
synced 2026-06-05 23:10:16 +00:00
fixed gevent problem
This commit is contained in:
+17
-13
@@ -103,23 +103,27 @@ class Request(object):
|
||||
|
||||
_handlers = []
|
||||
|
||||
if self.auth:
|
||||
|
||||
authr = urllib2.HTTPPasswordMgrWithDefaultRealm()
|
||||
if self.auth or self.cookiejar:
|
||||
|
||||
authr.add_password(None, self.url, self.auth.username, self.auth.password)
|
||||
auth_handler = urllib2.HTTPBasicAuthHandler(authr)
|
||||
if self.auth:
|
||||
|
||||
_handlers.append(auth_handler)
|
||||
authr = urllib2.HTTPPasswordMgrWithDefaultRealm()
|
||||
|
||||
if self.cookiejar:
|
||||
|
||||
cookie_handler = urllib2.HTTPCookieProcessor(cookiejar)
|
||||
_handlers.append(cookie_handler)
|
||||
authr.add_password(None, self.url, self.auth.username, self.auth.password)
|
||||
auth_handler = urllib2.HTTPBasicAuthHandler(authr)
|
||||
|
||||
|
||||
opener = urllib2.build_opener(*_handlers)
|
||||
return opener.open
|
||||
_handlers.append(auth_handler)
|
||||
|
||||
if self.cookiejar:
|
||||
|
||||
cookie_handler = urllib2.HTTPCookieProcessor(cookiejar)
|
||||
_handlers.append(cookie_handler)
|
||||
|
||||
opener = urllib2.build_opener(*_handlers)
|
||||
return opener.open
|
||||
|
||||
else:
|
||||
return urllib2.urlopen
|
||||
|
||||
|
||||
def _build_response(self, resp):
|
||||
|
||||
Reference in New Issue
Block a user