]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: do not send PROXY more than once
authorFata Nugraha <fatanugraha@outlook.com>
Wed, 9 Nov 2022 09:38:00 +0000 (16:38 +0700)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 10 Nov 2022 11:24:48 +0000 (12:24 +0100)
Unlike `CONNECT`, currently we don't keep track whether `PROXY` is
already sent or not. This causes `PROXY` header to be sent twice during
`MSTATE_TUNNELING` and `MSTATE_PROTOCONNECT`.

Closes #9878
Fixes #9442

lib/http.c
lib/urldata.h

index f5ccda8f6788dd5669dd90ba4ebe24283cebec24..90e6df19c05120e2b6e88d387f017dc93c6aeb92 100644 (file)
@@ -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
 
index 1ae7aa4a5ea4b3d1dcb3aaab146eedc34f8532ed..7f1acc4c5a35f10a0d1ae34ca6b3d6e4235d1e74 100644 (file)
@@ -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 */