Skip to content

Commit a7c3aed

Browse files
committed
connection: update session with proxies if available
It was erroneously assumed that new Session objects would include proxy details, especially when env vars are defined. Fixes an issue where users stuck behind a corporate firewall cannot reach the api endpoint because the underlying liburl requests is not updated. Check if proxies are available and update the Session. Signed-off-by: Jamie Couture <[email protected]>
1 parent 86c5665 commit a7c3aed

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

nasdaqdatalink/connection.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22

33
import requests
4+
import urllib
45

56
from urllib3.util.retry import Retry
67
from requests.adapters import HTTPAdapter
@@ -62,6 +63,10 @@ def get_session(cls):
6263
adapter = HTTPAdapter(max_retries=cls.get_retries())
6364
session.mount(ApiConfig.api_protocol, adapter)
6465

66+
proxies = urllib.request.getproxies()
67+
if proxies is not None:
68+
session.proxies.update(proxies)
69+
6570
return session
6671

6772
@classmethod

0 commit comments

Comments
 (0)