Repository: python-telegram-bot/python-telegram-bot

Issue:
No connect behind a proxy with authentication
<!--
Thanks for reporting issues of python-telegram-bot!
To make it easier for us to help you please enter detailed information below.
-->
### Steps to reproduce

1.Connection errors 
1. the user and pass is given in that format:

https_proxy=user:pass@proxydir:port

http_proxy=user:pass@proxydir:port
3.
### Expected behaviour

Tell us what should happen
### Actual behaviour

Tell us what happens instead
### Configuration

Debian "stretch"

**Version of Python:**

`$ python -V`ver 3.5

**Version of python-telegram-bot:**
4.3.3
`$ python -c 'import telegram; print(telegram.__version__)'`
### Logs

Insert logs here (if necessary)



Discussion:
Something like this?

```
Example using proxy authentication:
>>> headers = urllib3.make_headers(proxy_basic_auth=’myusername:mypassword’)
>>> proxy = urllib3.ProxyManager(’http://localhost:3128’, proxy_headers=headers)
>>> r = proxy.request(’GET’, ’http://example.com/’)
>>> r.status
```

@kalety thank you for the information.
if you'd like you can assist us with fixing the issue.
you can take a look at the file telegram/utils/request.py there you can see the code which retrieves the https_proxy env. var. 
according to your example it appears that an extra parsing to the user name and password is required and obviously some extra handing to pass it as headers.

I'm trying it...

;))

the problem still exist... repoening

there's `urllib3.proxy_from_url()` so no parsing is required.
i'm testing a solution at the moment

Ok!, tomorrow I'll try again. Thanks!. 

Enviado desde mi iPhone

> El 12 jul 2016, a las 21:59, Noam Meltzer notifications@github.com escribió:
> 
> there's urllib3.proxy_from_url() so no parsing is required.
> i'm testing a solution at the moment
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.


Resolving patch:
diff --git a/telegram/__init__.py b/telegram/__init__.py
--- a/telegram/__init__.py
+++ b/telegram/__init__.py
@@ -82,7 +82,7 @@
 from .bot import Bot
 
 __author__ = 'devs@python-telegram-bot.org'
-__version__ = '4.3.3'
+__version__ = '4.3.4'
 __all__ = ['Audio', 'Bot', 'Chat', 'ChatMember', 'ChatAction', 'ChosenInlineResult',
            'CallbackQuery', 'Contact', 'Document', 'Emoji', 'File', 'ForceReply',
            'InlineKeyboardButton', 'InlineKeyboardMarkup', 'InlineQuery', 'InlineQueryResult',
diff --git a/telegram/utils/request.py b/telegram/utils/request.py
--- a/telegram/utils/request.py
+++ b/telegram/utils/request.py
@@ -57,14 +57,17 @@ def _init_con_pool():
                   ])
     proxy_url = _get_con_pool_proxy()
     if not proxy_url:
-        mgr = urllib3.PoolManager
+        mgr = urllib3.PoolManager(**kwargs)
     else:
-        kwargs['proxy_url'] = proxy_url
         if _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():


Test patch: