misc: add a REQUESTS_PROXIES settings for requests calls (#20371)

This commit is contained in:
Thomas NOËL 2017-11-30 16:36:36 +01:00
parent 0b6ed7b305
commit 234f1499fa
2 changed files with 6 additions and 1 deletions

View File

@ -35,6 +35,7 @@ try:
except ImportError:
Image = None
from django.conf import settings
from django.utils import datetime_safe
from quixote import get_publisher, get_response, get_request
@ -289,7 +290,7 @@ def _http_request(url, method='GET', body=None, headers={}, cert_file=None, time
try:
response = requests.request(method, url, headers=headers, data=body,
timeout=timeout, cert=cert_file)
timeout=timeout, cert=cert_file, proxies=settings.REQUESTS_PROXIES)
except requests.Timeout:
raise ConnectionError('connection timed out while fetching the page')
except requests.RequestException as err:

View File

@ -146,6 +146,10 @@ CACHES = {
WCS_LEGACY_CONFIG_FILE = None
# proxies=REQUESTS_PROXIES is used in python-requests call
# http://docs.python-requests.org/en/master/user/advanced/?highlight=proxy#proxies
REQUESTS_PROXIES = None
local_settings_file = os.environ.get('WCS_SETTINGS_FILE',
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
if os.path.exists(local_settings_file):