[New-bugs-announce] [issue24599] urllib URLopener().open https url returns 501 Not Implemented when https_proxy env var is http://

Stefano Mazzucco report at bugs.python.org
Thu Jul 9 20:14:15 CEST 2015


New submission from Stefano Mazzucco:

Hello,

at work, I am behind a proxy (squid) that is only available over http. So, I have to configure both the http_proxy and https_proxy environment variables to be something like "http://proxy.corp.com:8181"

Now, when I try and use urllib to open an "https" url, the proxy returns "501 Not Implemented".


The quick and dirty script below is a minimal demonstration of the problem that appears on both python 2.7 (tested on 2.7.6, 2.7.9, 2.7.10) and 3.4 (tested on 3.4.0 and 3.4.4)

try:
    import urllib
    opener = urllib.URLopener()
except AttributeError:
    # Python 3
    import urllib.request
    opener = urllib.request.URLopener()

url = 'https://www.python.org'

print("Trying to open", url)

opener.open(url)


Changing the url to "http://" works OK.

Thanks,

-- Stefano

----------
components: Library (Lib)
messages: 246515
nosy: stefano-m
priority: normal
severity: normal
status: open
title: urllib URLopener().open  https url returns 501 Not Implemented when https_proxy env var is http://
type: behavior
versions: Python 2.7, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24599>
_______________________________________


More information about the New-bugs-announce mailing list