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

Unified Diff: utils/net.py

Issue 25615002: Monkey patch httplib on python <=2.6.2 to make it work with 'requests' library. (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
« no previous file with comments | « no previous file | 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 b66f11356c2a7eb2928aba910205a2296e3883f4..74e584af2ee7021d396051b502ab0dc61bc4dc4d 100644
--- a/utils/net.py
+++ b/utils/net.py
@@ -33,6 +33,20 @@ upload.logging = logging.getLogger('upload')
upload.logging.setLevel(logging.WARNING) # pylint: disable=E1103
+# TODO(vadimsh): Remove this once we don't have to support python 2.6 anymore.
+def monkey_patch_httplib():
+ """Patch httplib.HTTPConnection to have '_tunnel_host' attribute.
+
+ 'requests' library (>= v2) accesses 'HTTPConnection._tunnel_host' attribute
+ added only in python 2.6.3. This function patches HTTPConnection to have it
+ on python 2.6.2 as well.
+ """
+ conn = httplib.HTTPConnection('example.com')
+ if not hasattr(conn, '_tunnel_host'):
+ httplib.HTTPConnection._tunnel_host = None
+monkey_patch_httplib()
+
+
# Big switch that controls what API to use to make HTTP requests.
# It's temporary here to simplify benchmarking of old vs new implementation.
USE_REQUESTS_LIB = True
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698