Skip to content

Commit 7c908db

Browse files
committed
urllib3: can now connect through proxies which require auth
fixes python-telegram-bot#343
1 parent 27e57bb commit 7c908db

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

telegram/utils/request.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,17 @@ def _init_con_pool():
5757
])
5858
proxy_url = _get_con_pool_proxy()
5959
if not proxy_url:
60-
mgr = urllib3.PoolManager
60+
mgr = urllib3.PoolManager(**kwargs)
6161
else:
62-
kwargs['proxy_url'] = proxy_url
6362
if _CON_POOL_PROXY_KWARGS:
6463
kwargs.update(_CON_POOL_PROXY_KWARGS)
65-
mgr = urllib3.ProxyManager
64+
mgr = urllib3.proxy_from_url(proxy_url, **kwargs)
65+
if mgr.proxy.auth:
66+
# TODO: what about other auth types?
67+
auth_hdrs = urllib3.make_headers(proxy_basic_auth=mgr.proxy.auth)
68+
mgr.proxy_headers.update(auth_hdrs)
6669

67-
_CON_POOL = mgr(**kwargs)
70+
_CON_POOL = mgr
6871

6972

7073
def is_con_pool_initialized():

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy