Handle Google App Engine not setting _tunnel_host
MODIFY
src/urllib3/connection.py
src/urllib3/connection.py
@@ -171,7 +171,8 @@ class HTTPConnection(_HTTPConnection, object):
def _prepare_conn(self, conn):
self.sock = conn
- if self._tunnel_host:
+ # Google App Engine's httplib does not define _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
@@ -305,7 +306,8 @@ class VerifiedHTTPSConnection(HTTPSConnection):
conn = self._new_conn()
hostname = self.host
- if self._tunnel_host:
+ # Google App Engine's httplib does 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.

Handle Google App Engine not setting _tunnel_host (#1527)