From: Kenneth Reitz Date: Mon, 14 Feb 2011 17:39:13 +0000 (-0500) Subject: fixed gevent problem X-Git-Tag: v0.2.2^2~1^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=16e5119b2ad8be05673b5f8762cd71edaa0cd882;p=services%2Fpython-requests.git fixed gevent problem --- diff --git a/requests/core.py b/requests/core.py index d04ef72..5f61416 100644 --- a/requests/core.py +++ b/requests/core.py @@ -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):