mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
CONNECT: fix ipv6 address in the Request-Line
Commit 466150bc64
fixed the Host: header with CONNECT, but I then
forgot the preceeding request-line. Now this too uses [brackets]
properly if a ipv6 numerical address was given.
Bug: http://curl.haxx.se/bug/view.cgi?id=3493129
Reported by: "Blacat"
This commit is contained in:
parent
5430007222
commit
79b6f4a2d3
@ -124,11 +124,15 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
|||||||
const char *useragent="";
|
const char *useragent="";
|
||||||
const char *http = (conn->proxytype == CURLPROXY_HTTP_1_0) ?
|
const char *http = (conn->proxytype == CURLPROXY_HTTP_1_0) ?
|
||||||
"1.0" : "1.1";
|
"1.0" : "1.1";
|
||||||
|
char *hostheader= /* host:port with IPv6 support */
|
||||||
|
aprintf("%s%s%s:%hu", conn->bits.ipv6_ip?"[":"",
|
||||||
|
hostname, conn->bits.ipv6_ip?"]":"",
|
||||||
|
remote_port);
|
||||||
|
if(!hostheader)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if(!Curl_checkheaders(data, "Host:")) {
|
if(!Curl_checkheaders(data, "Host:")) {
|
||||||
host = aprintf("Host: %s%s%s:%hu\r\n", conn->bits.ipv6_ip?"[":"",
|
host = aprintf("Host: %s\r\n", hostheader);
|
||||||
hostname, conn->bits.ipv6_ip?"]":"",
|
|
||||||
remote_port);
|
|
||||||
if(!host) {
|
if(!host) {
|
||||||
free(req_buffer);
|
free(req_buffer);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
@ -141,24 +145,24 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
|||||||
data->set.str[STRING_USERAGENT])
|
data->set.str[STRING_USERAGENT])
|
||||||
useragent = conn->allocptr.uagent;
|
useragent = conn->allocptr.uagent;
|
||||||
|
|
||||||
/* Send the connect request to the proxy */
|
|
||||||
/* BLOCKING */
|
|
||||||
result =
|
result =
|
||||||
Curl_add_bufferf(req_buffer,
|
Curl_add_bufferf(req_buffer,
|
||||||
"CONNECT %s:%hu HTTP/%s\r\n"
|
"CONNECT %s HTTP/%s\r\n"
|
||||||
"%s" /* Host: */
|
"%s" /* Host: */
|
||||||
"%s" /* Proxy-Authorization */
|
"%s" /* Proxy-Authorization */
|
||||||
"%s" /* User-Agent */
|
"%s" /* User-Agent */
|
||||||
"%s", /* Proxy-Connection */
|
"%s", /* Proxy-Connection */
|
||||||
hostname, remote_port, http,
|
hostheader,
|
||||||
host,
|
http,
|
||||||
conn->allocptr.proxyuserpwd?
|
host,
|
||||||
conn->allocptr.proxyuserpwd:"",
|
conn->allocptr.proxyuserpwd?
|
||||||
useragent,
|
conn->allocptr.proxyuserpwd:"",
|
||||||
proxyconn);
|
useragent,
|
||||||
|
proxyconn);
|
||||||
|
|
||||||
if(host && *host)
|
if(host && *host)
|
||||||
free(host);
|
free(host);
|
||||||
|
free(hostheader);
|
||||||
|
|
||||||
if(CURLE_OK == result)
|
if(CURLE_OK == result)
|
||||||
result = Curl_add_custom_headers(conn, req_buffer);
|
result = Curl_add_custom_headers(conn, req_buffer);
|
||||||
@ -168,7 +172,8 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
|||||||
result = Curl_add_bufferf(req_buffer, "\r\n");
|
result = Curl_add_bufferf(req_buffer, "\r\n");
|
||||||
|
|
||||||
if(CURLE_OK == result) {
|
if(CURLE_OK == result) {
|
||||||
/* Now send off the request */
|
/* Send the connect request to the proxy */
|
||||||
|
/* BLOCKING */
|
||||||
result =
|
result =
|
||||||
Curl_add_buffer_send(req_buffer, conn,
|
Curl_add_buffer_send(req_buffer, conn,
|
||||||
&data->info.request_size, 0, sockindex);
|
&data->info.request_size, 0, sockindex);
|
||||||
|
Loading…
Reference in New Issue
Block a user