]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: httpclient: Don't set EOM flag on an empty HTX message
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Oct 2022 13:10:24 +0000 (15:10 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Oct 2022 13:18:25 +0000 (15:18 +0200)
In the HTTP client, when the request body is streamed, at the end of the
payload, we must be sure to not set the EOM flag on an empty message.
Otherwise, because there is no data, the buffer is reset to be released and
the flag is lost. Thus, the HTTP client is never notified of the end of
payload for the request and the applet is blocked. If the HTTP client is
instanciated from a Lua script, it is even worse because we fall into a
wakeup loop between the lua script and the HTTP client applet. At the end,
HAProxy is killed because of the watchdog.

This patch should fix the issue #1898. It must be backported to 2.6.

src/http_client.c

index e2af029559572358838d7286759d6be1c5c33c5d..cd12a8e7fede501552d03c558c9cf1fe0a1d21c8 100644 (file)
@@ -421,6 +421,16 @@ int httpclient_req_xfer(struct httpclient *hc, struct ist src, int end)
 
        /* if we copied all the data and the end flag is set */
        if ((istlen(src) == ret) && end) {
+               /* no more data are expected. If the HTX buffer is empty, be
+                * sure to add something (EOT block in this case) to have
+                * something to send. It is important to be sure the EOM flags
+                * will be handled by the endpoint. Because the message is
+                * empty, this should not fail. Otherwise it is an error
+                */
+               if (htx_is_empty(htx)) {
+                       if (!htx_add_endof(htx, HTX_BLK_EOT))
+                               goto error;
+               }
                htx->flags |= HTX_FL_EOM;
        }
        htx_to_buf(htx, &hc->req.buf);