[New-bugs-announce] [issue34516] httplib sets unbefitting "Host" in request header when requests an ipv6 format url.
chen wu
report at bugs.python.org
Mon Aug 27 02:52:34 EDT 2018
New submission from chen wu <wuchen12 at huawei.com>:
when I tried to request a url like "https://[fc00:0a08::2]:35357", I got 400.
The code is like:
import requests
requests.get("https://[fc00:0a08::2]:35357", verify=False)
And the apache logs:
vhost.c(889): [client fc00:ac1c::9a5:58692] AH00550: Client sent malformed Host header: [[fc00::0a08::2]]:35357
If user no set "Host" in header, httpslib will pase it from url and set it.
The paser function is urllib3.util.url.pase_url. When url is "https://[fc00:0a08::2]:35357", we got host [fc00:0a08::2].
And then httplib sets host in putrequest, "[" and "]" will be added to [fc00:0a08::2], which is not a valid format for host.
The part of codes are:
974 # Wrap the IPv6 Host Header with [] (RFC 2732)
975 if host_enc.find(':') >= 0:
976 host_enc = "[" + host_enc + "]"
maybe the judgement condition for wrap ipv6 host header with [] is not very well?
----------
components: Library (Lib)
messages: 324149
nosy: visionwun
priority: normal
severity: normal
status: open
title: httplib sets unbefitting "Host" in request header when requests an ipv6 format url.
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34516>
_______________________________________
More information about the New-bugs-announce
mailing list