Martin Panter <vadmium...@gmail.com> added the comment:

Gregory, I haven’t tried recent Python code, but I expect the problem with 
percent decoding is still there. If you did try my example, what results did 
you see? Be aware that these techniques only work if the OS co-operates and 
connects to localhost when you give it the longer host string. At the moment I 
have glibc 2.26 on x86-64 Linux.

In the Python 3 master branch, the percent-encoding should be decoded in 
“urllib.request.Request._parse”:

def _parse(self):
    ...
    self.host, self.selector = _splithost(rest)
    if self.host:
        self.host = unquote(self.host)

Then in “AbstractHTTPHandler.do_request_” the decoded host string becomes the 
“Host” header field value, without any encoding:

def do_request_(self, request):
    host = request.host
    ...
    sel_host = host
    ...
    if not request.has_header('Host'):
        request.add_unredirected_header('Host', sel_host)

Perhaps one solution to both my version and Orange’s original version is to 
encode the “Host” header field value properly. This might also apply to the 
“http.client” code.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue30458>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to