Merge pull request #583 from whipermr5/gae-urllib3-support

Compatibility with GAE via urllib3.contrib package
This commit is contained in:
Noam Meltzer 2017-04-29 12:29:51 +03:00 committed by GitHub
commit 284f16b87b
2 changed files with 7 additions and 1 deletions

View file

@ -24,6 +24,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Jacob Bom <https://github.com/bomjacob>`_
- `JASON0916 <https://github.com/JASON0916>`_
- `jh0ker <https://github.com/jh0ker>`_
- `John Yong <https://github.com/whipermr5>`_
- `jossalgon <https://github.com/jossalgon>`_
- `JRoot3D <https://github.com/JRoot3D>`_
- `jlmadurga <https://github.com/jlmadurga>`_

View file

@ -28,6 +28,7 @@ except ImportError:
import certifi
import urllib3
import urllib3.contrib.appengine
from urllib3.connection import HTTPConnection
from urllib3.util.timeout import Timeout
try:
@ -93,7 +94,11 @@ class Request(object):
proxy_url = os.environ.get('HTTPS_PROXY') or os.environ.get('https_proxy')
if not proxy_url:
mgr = urllib3.PoolManager(**kwargs)
if urllib3.contrib.appengine.is_appengine_sandbox():
# Use URLFetch service if running in App Engine
mgr = urllib3.contrib.appengine.AppEngineManager()
else:
mgr = urllib3.PoolManager(**kwargs)
else:
kwargs.update(urllib3_proxy_kwargs)
if proxy_url.startswith('socks'):