Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 208e9c6

Browse files
authored
Merge pull request python-telegram-bot#348 from python-telegram-bot/urllib3_fix_proxy_auth
Urllib3 fix proxy auth
2 parents 27e57bb + 6016aca commit 208e9c6

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

CHANGES.rst

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
**2016-07-12**
2+
3+
*Released 4.3.4*
4+
5+
- Fix proxy support with ``urllib3`` when proxy requires auth
6+
17
**2016-07-08**
28

39
*Released 4.3.3*

telegram/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
from .bot import Bot
8383

8484
__author__ = '[email protected]'
85-
__version__ = '4.3.3'
85+
__version__ = '4.3.4'
8686
__all__ = ['Audio', 'Bot', 'Chat', 'ChatMember', 'ChatAction', 'ChosenInlineResult',
8787
'CallbackQuery', 'Contact', 'Document', 'Emoji', 'File', 'ForceReply',
8888
'InlineKeyboardButton', 'InlineKeyboardMarkup', 'InlineQuery', 'InlineQueryResult',

telegram/utils/request.py

+7-4
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)