Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1249)

Unified Diff: utils/net.py

Issue 25004007: Update 'requests' lib to v2.0. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/swarm_client
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« third_party/requests/README.swarming ('K') | « third_party/requests/utils.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/net.py
diff --git a/utils/net.py b/utils/net.py
index 1a93d4ad6e4ce4d60a0e8cf64ac4789f3b2354a4..e36708649726ec50954018c922ff020fc3fdf329 100644
--- a/utils/net.py
+++ b/utils/net.py
@@ -385,6 +385,8 @@ class HttpService(object):
if self.authenticator and self.authenticator.authenticate():
# Success! Run request again immediately.
attempt.skip_sleep = True
+ # Also refresh cookies used by request engine.
+ self.engine.reload_cookies()
continue
# Authentication attempt was unsuccessful.
logging.error(
@@ -506,6 +508,11 @@ class RequestEngine(object):
"""
raise NotImplementedError()
+ def reload_cookies(self):
+ """Reloads cookies from original cookie jar."""
+ # This method is optional.
+ pass
+
class Authenticator(object):
"""Base class for objects that know how to authenticate into http services."""
@@ -558,6 +565,7 @@ class RequestsLibEngine(RequestEngine):
def __init__(self, cookie_jar, ca_certs):
super(RequestsLibEngine, self).__init__()
self.session = requests.Session()
+ self.cookie_jar = cookie_jar
# Configure session.
self.session.trust_env = False
if cookie_jar:
@@ -594,6 +602,10 @@ class RequestsLibEngine(RequestEngine):
except (requests.ConnectionError, socket.timeout, ssl.SSLError) as e:
raise ConnectionError(e)
+ def reload_cookies(self):
+ if self.cookie_jar:
+ self.session.cookies = self.cookie_jar
+
class AppEngineAuthenticator(Authenticator):
"""Helper class to perform AppEngine authentication dance via upload.py."""
« third_party/requests/README.swarming ('K') | « third_party/requests/utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698