diff --git a/lib/http.c b/lib/http.c index f5ccda8f67..90e6df19c0 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1572,11 +1572,14 @@ CURLcode Curl_http_connect(struct Curl_easy *data, bool *done) /* nothing else to do except wait right now - we're not done here. */ return CURLE_OK; - if(data->set.haproxyprotocol) { + if(data->set.haproxyprotocol && !data->state.is_haproxy_hdr_sent) { /* add HAProxy PROXY protocol header */ result = add_haproxy_protocol_header(data); if(result) return result; + + /* do not send the header again after successful try */ + data->state.is_haproxy_hdr_sent = TRUE; } #endif diff --git a/lib/urldata.h b/lib/urldata.h index 1ae7aa4a5e..7f1acc4c5a 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1461,6 +1461,10 @@ struct UrlState { trailers_state trailers_state; /* whether we are sending trailers and what stage are we at */ #endif +#ifndef CURL_DISABLE_PROXY + /* to keep track whether we already sent PROXY header or not */ + BIT(is_haproxy_hdr_sent); +#endif #ifdef USE_HYPER bool hconnect; /* set if a CONNECT request */ CURLcode hresult; /* used to pass return codes back from hyper callbacks */