mirror of https://github.com/moparisthebest/curl
http: make the haproxy support work with unix domain sockets
... it should then pass on "PROXY UNKNOWN" since it doesn't know the involved IP addresses. Reported-by: Valentín Gutiérrez Fixes #7290 Closes #7291
This commit is contained in:
parent
cfaa035a0c
commit
a629506d42
31
lib/http.c
31
lib/http.c
|
@ -1537,38 +1537,35 @@ static int http_getsock_do(struct Curl_easy *data,
|
||||||
#ifndef CURL_DISABLE_PROXY
|
#ifndef CURL_DISABLE_PROXY
|
||||||
static CURLcode add_haproxy_protocol_header(struct Curl_easy *data)
|
static CURLcode add_haproxy_protocol_header(struct Curl_easy *data)
|
||||||
{
|
{
|
||||||
char proxy_header[128];
|
|
||||||
struct dynbuf req;
|
struct dynbuf req;
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
char tcp_version[5];
|
const char *tcp_version;
|
||||||
DEBUGASSERT(data->conn);
|
DEBUGASSERT(data->conn);
|
||||||
|
Curl_dyn_init(&req, DYN_HAXPROXY);
|
||||||
|
|
||||||
/* Emit the correct prefix for IPv6 */
|
#ifdef USE_UNIX_SOCKETS
|
||||||
if(data->conn->bits.ipv6) {
|
if(data->conn->unix_domain_socket)
|
||||||
strcpy(tcp_version, "TCP6");
|
/* the buffer is large enough to hold this! */
|
||||||
}
|
result = Curl_dyn_add(&req, "PROXY UNKNOWN\r\n");
|
||||||
else {
|
else {
|
||||||
strcpy(tcp_version, "TCP4");
|
#endif
|
||||||
}
|
/* Emit the correct prefix for IPv6 */
|
||||||
|
tcp_version = data->conn->bits.ipv6 ? "TCP6" : "TCP4";
|
||||||
|
|
||||||
msnprintf(proxy_header,
|
result = Curl_dyn_addf(&req, "PROXY %s %s %s %i %i\r\n",
|
||||||
sizeof(proxy_header),
|
|
||||||
"PROXY %s %s %s %i %i\r\n",
|
|
||||||
tcp_version,
|
tcp_version,
|
||||||
data->info.conn_local_ip,
|
data->info.conn_local_ip,
|
||||||
data->info.conn_primary_ip,
|
data->info.conn_primary_ip,
|
||||||
data->info.conn_local_port,
|
data->info.conn_local_port,
|
||||||
data->info.conn_primary_port);
|
data->info.conn_primary_port);
|
||||||
|
|
||||||
Curl_dyn_init(&req, DYN_HAXPROXY);
|
#ifdef USE_UNIX_SOCKETS
|
||||||
|
}
|
||||||
result = Curl_dyn_add(&req, proxy_header);
|
#endif
|
||||||
if(result)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
|
if(!result)
|
||||||
result = Curl_buffer_send(&req, data, &data->info.request_size,
|
result = Curl_buffer_send(&req, data, &data->info.request_size,
|
||||||
0, FIRSTSOCKET);
|
0, FIRSTSOCKET);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue