Merge branch 'urllib3_fix_proxy_auth'

This commit is contained in:
Jannes Höke 2016-07-13 15:09:23 +02:00
commit 81a755a7d8
3 changed files with 14 additions and 5 deletions

View file

@ -1,3 +1,9 @@
**2016-07-12**
*Released 4.3.4*
- Fix proxy support with ``urllib3`` when proxy requires auth
**2016-07-08** **2016-07-08**
*Released 4.3.3* *Released 4.3.3*

View file

@ -82,7 +82,7 @@ from .update import Update
from .bot import Bot from .bot import Bot
__author__ = 'devs@python-telegram-bot.org' __author__ = 'devs@python-telegram-bot.org'
__version__ = '4.3.3' __version__ = '4.3.4'
__all__ = ['Audio', 'Bot', 'Chat', 'ChatMember', 'ChatAction', 'ChosenInlineResult', __all__ = ['Audio', 'Bot', 'Chat', 'ChatMember', 'ChatAction', 'ChosenInlineResult',
'CallbackQuery', 'Contact', 'Document', 'Emoji', 'File', 'ForceReply', 'CallbackQuery', 'Contact', 'Document', 'Emoji', 'File', 'ForceReply',
'InlineKeyboardButton', 'InlineKeyboardMarkup', 'InlineQuery', 'InlineQueryResult', 'InlineKeyboardButton', 'InlineKeyboardMarkup', 'InlineQuery', 'InlineQueryResult',

View file

@ -57,14 +57,17 @@ def _init_con_pool():
]) ])
proxy_url = _get_con_pool_proxy() proxy_url = _get_con_pool_proxy()
if not proxy_url: if not proxy_url:
mgr = urllib3.PoolManager mgr = urllib3.PoolManager(**kwargs)
else: else:
kwargs['proxy_url'] = proxy_url
if _CON_POOL_PROXY_KWARGS: if _CON_POOL_PROXY_KWARGS:
kwargs.update(_CON_POOL_PROXY_KWARGS) kwargs.update(_CON_POOL_PROXY_KWARGS)
mgr = urllib3.ProxyManager mgr = urllib3.proxy_from_url(proxy_url, **kwargs)
if mgr.proxy.auth:
# TODO: what about other auth types?
auth_hdrs = urllib3.make_headers(proxy_basic_auth=mgr.proxy.auth)
mgr.proxy_headers.update(auth_hdrs)
_CON_POOL = mgr(**kwargs) _CON_POOL = mgr
def is_con_pool_initialized(): def is_con_pool_initialized():