]> git.kaiwu.me - haproxy.git/commitdiff
MEDIUM: http-ana: Use the version of the opposite side for internal messages
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 25 Feb 2026 15:29:26 +0000 (16:29 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 Mar 2026 14:34:46 +0000 (15:34 +0100)
When the response is send by HAProxy, from a applet or for the analyzers,
The request version is used for the response. The main reason is that there
is not real version for the response when this happens. "HTTP/1.1" is used,
but it is in fact just an HTX response. So the version of the request is
used.

In the same manner, when the request is sent from an applet (httpclient),
the response version is used, once available.

The purpose of this change is to return the most accurate version from the
user point of view.

src/http_ana.c

index 399c75906821a3fe0f0a9c3f75f0a51b8efaa0b1..a746ed96e034f081ccb98988c4d7e313045ec65a 100644 (file)
@@ -1475,12 +1475,20 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                /* Not an HTTP response */
                msg->vsn = 0;
        }
-       else {
+       else if (objt_server(s->target)) {
                /* HTTP response from a server, use it to set the response version */
                char *ptr;
 
                ptr = HTX_SL_RES_VPTR(sl);
                msg->vsn = ((ptr[5] - '0') << 4) + (ptr[7] - '0');
+
+               /* If front endpoint is an applet, use the server version for the request */
+               if (sc_ep_test(s->scf, SE_FL_T_APPLET))
+                       txn->req.vsn = msg->vsn;
+       }
+       else {
+               /* HTTP response from an applet, use the request version for the response */
+               msg->vsn = txn->req.vsn;
        }
 
        /* Adjust server's health based on status code. Note: status codes 501
@@ -4728,6 +4736,9 @@ int http_forward_proxy_resp(struct stream *s, int final)
                if (s->txn->meth == HTTP_METH_HEAD)
                        htx_skip_msg_payload(htx);
 
+               /* Respnse from haproxy, override HTTP response verison using the request one */
+               s->txn->rsp.vsn = s->txn->req.vsn;
+
                channel_auto_read(req);
                channel_abort(req);
                channel_htx_erase(req, htxbuf(&req->buf));