]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h3/qmux: Set QC_SF_UNKNOWN_PL_LENGTH flag on QCS when headers are sent
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 18 Sep 2025 07:25:31 +0000 (09:25 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 8 Oct 2025 09:01:36 +0000 (11:01 +0200)
QC_SF_UNKNOWN_PL_LENGTH flag is set on the qcs to know a payload of message
has an unknown length and not send a RESET_STREAM on shutdown. This flag was
based on the HTX extra field value. However, it is not necessary. When
headers are processed, before sending them, it is possible to check the HTX
start-line to know if the length of the payload is known or not.

So let's do so and don't use anymore the HTX extra field for this purpose.

src/h3.c
src/qmux_http.c

index fdad3b06855ff4b0c6a1772f98474878fb973fcd..e0a1233d52ffc8fc242ccef9409bb3f5c76a1c83 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -2123,6 +2123,15 @@ static int h3_req_headers_send(struct qcs *qcs, struct htx *htx)
                        goto err_full;
        }
 
+       if (!(sl->flags & HTX_SL_F_XFER_LEN)) {
+               /* Extra care required for HTTP/1 responses without Content-Length nor
+                * chunked encoding. In this case, shutw callback will be use to signal
+                * the end of the message. QC_SF_UNKNOWN_PL_LENGTH is set to prevent a
+                * RESET_STREAM emission in this case.
+                */
+               qcs->flags |= QC_SF_UNKNOWN_PL_LENGTH;
+       }
+
        /* Encode every parsed headers, stop at empty one. */
        for (hdr = 0; hdr < sizeof(list) / sizeof(list[0]); ++hdr) {
                if (isteq(list[hdr].n, ist("")))
@@ -2307,6 +2316,15 @@ static int h3_resp_headers_send(struct qcs *qcs, struct htx *htx)
                goto err_full;
        }
 
+       if (!(sl->flags & HTX_SL_F_XFER_LEN)) {
+               /* Extra care required for HTTP/1 responses without Content-Length nor
+                * chunked encoding. In this case, shutw callback will be use to signal
+                * the end of the message. QC_SF_UNKNOWN_PL_LENGTH is set to prevent a
+                * RESET_STREAM emission in this case.
+                */
+               qcs->flags |= QC_SF_UNKNOWN_PL_LENGTH;
+       }
+
        for (hdr = 0; hdr < sizeof(list) / sizeof(list[0]); ++hdr) {
                if (isteq(list[hdr].n, ist("")))
                        break;
index 9a310a397370df33b1b6eb627ecf94070e1ccda0..552e16821d4ee0e01b6f74fc8cfccef912758b32 100644 (file)
@@ -95,23 +95,10 @@ int qcs_http_handle_standalone_fin(struct qcs *qcs)
 size_t qcs_http_snd_buf(struct qcs *qcs, struct buffer *buf, size_t count,
                         char *fin)
 {
-       struct htx *htx;
        size_t ret;
 
        TRACE_ENTER(QMUX_EV_STRM_SEND, qcs->qcc->conn, qcs);
-
-       htx = htxbuf(buf);
-
-       /* Extra care required for HTTP/1 responses without Content-Length nor
-        * chunked encoding. In this case, shutw callback will be use to signal
-        * the end of the message. QC_SF_UNKNOWN_PL_LENGTH is set to prevent a
-        * RESET_STREAM emission in this case.
-        */
-       if (htx->extra && htx->extra == HTX_UNKOWN_PAYLOAD_LENGTH)
-               qcs->flags |= QC_SF_UNKNOWN_PL_LENGTH;
-
        ret = qcs->qcc->app_ops->snd_buf(qcs, buf, count, fin);
-
        TRACE_LEAVE(QMUX_EV_STRM_SEND, qcs->qcc->conn, qcs);
 
        return ret;