From 45c2edf73c01af210de41e34b87dd7d0fa0994ec Mon Sep 17 00:00:00 2001 From: vapier Date: Thu, 16 Jun 2016 09:44:44 -0700 Subject: [PATCH] httplib2: update to 0.9.2 release This is in preparation for adding py3 support. Review-Url: https://codereview.chromium.org/2073823002 --- third_party/httplib2/README.chromium | 6 ++-- third_party/httplib2/__init__.py | 46 +++++++++++++++++++--------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/third_party/httplib2/README.chromium b/third_party/httplib2/README.chromium index 39e25b0a6..b4b349fb1 100644 --- a/third_party/httplib2/README.chromium +++ b/third_party/httplib2/README.chromium @@ -1,8 +1,8 @@ Name: httplib2 Short Name: httplib2 -URL: https://github.com/jcgregorio/httplib2 -Version: 0.8 -Revision: 0197ec868a4fc638c08358b94200ffd6ddb1bf50 +URL: https://github.com/httplib2/httplib2 +Version: 0.9.2 +Revision: cf631a73e2f3f43897b65206127ced82382d35f5 License: MIT License Description: diff --git a/third_party/httplib2/__init__.py b/third_party/httplib2/__init__.py index 8825e5dc8..6fa3cc60e 100644 --- a/third_party/httplib2/__init__.py +++ b/third_party/httplib2/__init__.py @@ -22,7 +22,7 @@ __contributors__ = ["Thomas Broyer (t.broyer@ltgt.net)", "Sam Ruby", "Louis Nyffenegger"] __license__ = "MIT" -__version__ = "0.8" +__version__ = "0.9.2" import re import sys @@ -749,12 +749,27 @@ class ProxyInfo(object): bypass_hosts = () def __init__(self, proxy_type, proxy_host, proxy_port, - proxy_rdns=None, proxy_user=None, proxy_pass=None): - """The parameter proxy_type must be set to one of socks.PROXY_TYPE_XXX - constants. For example: + proxy_rdns=True, proxy_user=None, proxy_pass=None): + """ + Args: + proxy_type: The type of proxy server. This must be set to one of + socks.PROXY_TYPE_XXX constants. For example: + + p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, + proxy_host='localhost', proxy_port=8000) + + proxy_host: The hostname or IP address of the proxy server. + + proxy_port: The port that the proxy server is running on. - p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, - proxy_host='localhost', proxy_port=8000) + proxy_rdns: If True (default), DNS queries will not be performed + locally, and instead, handed to the proxy to resolve. This is useful + if the network does not allow resolution of non-local names. In + httplib2 0.9 and earlier, this defaulted to False. + + proxy_user: The username used to authenticate with the proxy server. + + proxy_pass: The password used to authenticate with the proxy server. """ self.proxy_type = proxy_type self.proxy_host = proxy_host @@ -871,12 +886,12 @@ class HTTPConnectionWithTimeout(httplib.HTTPConnection): if self.proxy_info and self.proxy_info.isgood(): use_proxy = True proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass = self.proxy_info.astuple() - else: - use_proxy = False - if use_proxy and proxy_rdns: + host = proxy_host port = proxy_port else: + use_proxy = False + host = self.host port = self.port @@ -993,12 +1008,12 @@ class HTTPSConnectionWithTimeout(httplib.HTTPSConnection): if self.proxy_info and self.proxy_info.isgood(): use_proxy = True proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass = self.proxy_info.astuple() - else: - use_proxy = False - if use_proxy and proxy_rdns: + host = proxy_host port = proxy_port else: + use_proxy = False + host = self.host port = self.port @@ -1270,8 +1285,9 @@ class Http(object): err = getattr(e, 'args')[0] else: err = e.errno - if err == errno.ECONNREFUSED: # Connection refused - raise + if err in (errno.ENETUNREACH, errno.EADDRNOTAVAIL) and i < RETRIES: + continue # retry on potentially transient socket errors + raise except httplib.HTTPException: # Just because the server closed the connection doesn't apparently mean # that the server didn't send a response. @@ -1481,7 +1497,7 @@ class Http(object): info = email.Message.Message() cached_value = None if self.cache: - cachekey = defrag_uri + cachekey = defrag_uri.encode('utf-8') cached_value = self.cache.get(cachekey) if cached_value: # info = email.message_from_string(cached_value)