diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-06-23 16:02:12 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-06-24 09:01:49 +0200 |
commit | a629506d422f8f61a041a3ac579e136b4fab98ba (patch) | |
tree | 29a13a480b44488f1d5d50c93718596383c05ade /lib | |
parent | cfaa035a0c65040116523362c3f608c0b35ad733 (diff) | |
download | curl-a629506d422f8f61a041a3ac579e136b4fab98ba.tar.gz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/http.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/lib/http.c b/lib/http.c index f0cb9f794..6d5d8fb3b 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1537,38 +1537,35 @@ static int http_getsock_do(struct Curl_easy *data, #ifndef CURL_DISABLE_PROXY static CURLcode add_haproxy_protocol_header(struct Curl_easy *data) { - char proxy_header[128]; struct dynbuf req; CURLcode result; - char tcp_version[5]; + const char *tcp_version; DEBUGASSERT(data->conn); + Curl_dyn_init(&req, DYN_HAXPROXY); - /* Emit the correct prefix for IPv6 */ - if(data->conn->bits.ipv6) { - strcpy(tcp_version, "TCP6"); - } +#ifdef USE_UNIX_SOCKETS + if(data->conn->unix_domain_socket) + /* the buffer is large enough to hold this! */ + result = Curl_dyn_add(&req, "PROXY UNKNOWN\r\n"); else { - strcpy(tcp_version, "TCP4"); - } - - msnprintf(proxy_header, - sizeof(proxy_header), - "PROXY %s %s %s %i %i\r\n", - tcp_version, - data->info.conn_local_ip, - data->info.conn_primary_ip, - data->info.conn_local_port, - data->info.conn_primary_port); - - Curl_dyn_init(&req, DYN_HAXPROXY); +#endif + /* Emit the correct prefix for IPv6 */ + tcp_version = data->conn->bits.ipv6 ? "TCP6" : "TCP4"; - result = Curl_dyn_add(&req, proxy_header); - if(result) - return result; + result = Curl_dyn_addf(&req, "PROXY %s %s %s %i %i\r\n", + tcp_version, + data->info.conn_local_ip, + data->info.conn_primary_ip, + data->info.conn_local_port, + data->info.conn_primary_port); - result = Curl_buffer_send(&req, data, &data->info.request_size, - 0, FIRSTSOCKET); +#ifdef USE_UNIX_SOCKETS + } +#endif + if(!result) + result = Curl_buffer_send(&req, data, &data->info.request_size, + 0, FIRSTSOCKET); return result; } #endif |