Repository navigation
Closed
Labels
3.16new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
Description
| BPO | 7291 |
|---|---|
| Nosy | @ronaldoussoren, @orsenthil, @vadmium, @yan12125, @OneMoreZanuda |
| Files |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = 'https://github.com/orsenthil'
closed_at = None
created_at = <Date 2009-11-09.04:38:16.601>
labels = ['3.8', '3.7', 'library', '3.9', '3.10']
title = 'urllib2 cannot handle https with proxy requiring auth'
updated_at = <Date 2020-08-02.19:06:17.855>
user = 'https://bugs.python.org/tsujikawa'bugs.python.org fields:
activity = <Date 2020-08-02.19:06:17.855>
actor = 'alexey.namyotkin'
assignee = 'orsenthil'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2009-11-09.04:38:16.601>
creator = 'tsujikawa'
dependencies = []
files = ['15296', '15669', '20798', '20799', '20822', '20824', '34174']
hgrepos = []
issue_num = 7291
keywords = ['patch']
message_count = 24.0
messages = ['95058', '95060', '95373', '95377', '96659', '96660', '96661', '96844', '96845', '96846', '100840', '103090', '128861', '128862', '128952', '128953', '128955', '211850', '211860', '228406', '244513', '247805', '283306', '374687']
nosy_count = 11.0
nosy_names = ['ronaldoussoren', 'orsenthil', 'mbeachy', 'dieresys', 'tsujikawa', 'b.a.scott', 'martin.panter', 'vzafzal', 'yan12125', 'alexey.namyotkin', 'Jessica Ridgley']
pr_nums = []
priority = 'normal'
resolution = 'accepted'
stage = 'needs patch'
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue7291'
versions = ['Python 2.7', 'Python 3.5', 'Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']Linked PRs
Metadata
Metadata
Assignees
Labels
3.16new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
Projects
- StatusShow more project fieldsDone
Activity
tsujikawa commentedon Nov 9, 2009
urllib2 cannot handle https with proxy requiring authorization.
After https_proxy is set correctly,
This is because HTTPConnection::_tunnel() in httplib.py doesn't send
Proxy-Authorization header.
tsujikawa commentedon Nov 9, 2009
I created a patch.
I added additional argument 'headers' to HTTPConnection::set_tunnel()
method,
which is a mapping of HTTP headers to sent with CONNECT method. Since
authorization
credential is already set to Request object, in
AbstractHTTPHandler::do_open(),
if "Proxy-Authorization" header is found, pass it to set_tunnel().
It works fine for me.
ronaldoussoren commentedon Nov 17, 2009
The patch looks good to me.
IMHO this should be backported to 2.6 as well.
ronaldoussoren commentedon Nov 17, 2009
I've tested a backport of the patch to 2.6 (just replace set_proxy by
_set_proxy in the patch) and the resulting version of urllib2 can login to
the proxy (as expected).
Thanks for the patch.
orsenthil commentedon Dec 20, 2009
Fixed and Committed revision 76908 in the trunk.
orsenthil commentedon Dec 20, 2009
Fixed through reversions r76908, r76909, r76910, r76911
Thanks for the patch, Tatsuhiro Tsujikawa.
orsenthil commentedon Dec 20, 2009
meant revisions.
dieresys commentedon Dec 23, 2009
Hi! 2.6 backport is missing an argument in _set_tunnel definition. It
should be:
dieresys commentedon Dec 23, 2009
The patch fixes only when you pass the authentication info in the proxy
handler's URL. Like:
But setting the authentication using a ProxyBasicAuthHandler is still
broken:
In the attached file (urllib2_with_proxy_auth_comparison.py) we've wrote
a comparison between what works with HTTP and HTTPS.
The problem is the 407 error never reaches the ProxyBasicAuthHandler
because HTTPConnection._tunnel raises an exception when the http
response status code is not 200.
orsenthil commentedon Dec 24, 2009
Thanks for the note, Manuel. Fixed it in revision 77013.
orsenthil commentedon Mar 11, 2010
In this ticket, setting the authentication using a ProxyBasicAuthHandler is not yet addressed yet. (this was informed in the last note). Reopening this one to track it.
17 remaining items
orsenthil commentedon Nov 8, 2026
A fix for this issue - #161596
pythongh-51540: Let proxy auth handlers answer a 407 to CONNECT for h…
gh-51540: Let proxy auth handlers answer a 407 to CONNECT for https U…
pythongh-51540: Let proxy auth handlers answer a 407 to CONNECT for h…