| 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."""
|
|
|