[issue34516] httplib sets unbefitting "Host" in request header when requests an ipv6 format url.

chen wu report at bugs.python.org
Mon Aug 27 22:18:14 EDT 2018


chen wu <wuchen12 at huawei.com> added the comment:

Thanks so much for your reply. 

when httplib.HTTPConnection is inited with host [fc00::0a08::2] and port 35357, we can make a request normally. only the 'Host' set in header is wrong. I think the most simple way to fix this is adding judgement condition, maybe like this:
974                    # Wrap the IPv6 Host Header with [] (RFC 2732)
975                    if host_enc.find(':') >= 0 and host_enc.find(']') < 0:
976                        host_enc = "[" + host_enc + "]"

or rules should be given, because when port is not default, only (host=[aaa:bbb]:123, port=None) and (host=aaa:bbb, port=123) are valid for httplib now.

so sorry for my poor English. hope you can understand what im saying. :)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34516>
_______________________________________


More information about the Python-bugs-list mailing list