Lukasz Czekierda correctly pointed out that curl used a bad Host: header
when talking to a IPv6-server using IPv6 IP address only.
This commit is contained in:
13
lib/http.c
13
lib/http.c
@@ -581,13 +581,22 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
if(conn->allocptr.host)
|
||||
free(conn->allocptr.host);
|
||||
|
||||
/* When building Host: headers, we must put the host name within
|
||||
[brackets] if the host name is a plain IPv6-address. RFC2732-style. */
|
||||
|
||||
if(((conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTPS)) ||
|
||||
(!(conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTP)) )
|
||||
/* If (HTTPS on port 443) OR (non-HTTPS on port 80) then don't include
|
||||
the port number in the host string */
|
||||
conn->allocptr.host = aprintf("Host: %s\r\n", host);
|
||||
conn->allocptr.host = aprintf("Host: %s%s%s\r\n",
|
||||
conn->bits.ipv6_ip?"[":"",
|
||||
host,
|
||||
conn->bits.ipv6_ip?"]":"");
|
||||
else
|
||||
conn->allocptr.host = aprintf("Host: %s:%d\r\n", host,
|
||||
conn->allocptr.host = aprintf("Host: %s%s%s:%d\r\n",
|
||||
conn->bits.ipv6_ip?"[":"",
|
||||
host,
|
||||
conn->bits.ipv6_ip?"]":"",
|
||||
conn->remote_port);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user