From ae7f61243d06ffb29ca1f6396bed4bc285e55a28 Mon Sep 17 00:00:00 2001 From: speedplane Date: Wed, 19 Dec 2018 06:14:38 -0500 Subject: [PATCH] App Engine does not have _tunnel_host set in its httplib implementation. Make sure we check for that. #1503. Not this reverts part of the change in #1430. --- src/urllib3/connection.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/urllib3/connection.py b/src/urllib3/connection.py index ba269b7a13..e03ef0cf67 100644 --- a/src/urllib3/connection.py +++ b/src/urllib3/connection.py @@ -171,7 +171,7 @@ def _new_conn(self): def _prepare_conn(self, conn): self.sock = conn - if self._tunnel_host: + if getattr(self, '_tunnel_host', None): # TODO: Fix tunnel so it doesn't depend on self.sock state. self._tunnel() # Mark this connection as not reusable @@ -301,7 +301,8 @@ def connect(self): conn = self._new_conn() hostname = self.host - if self._tunnel_host: + # Google App Engine's different HTTP lib may not define_tunnel_host. + if getattr(self, '_tunnel_host', None): self.sock = conn # Calls self._set_hostport(), so self.host is # self._tunnel_host below.