From 586511c27886b3fab22cdd3e7b061a1f9b2225a7 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 18 Sep 2025 09:25:31 +0200 Subject: [PATCH] MINOR: h3/qmux: Set QC_SF_UNKNOWN_PL_LENGTH flag on QCS when headers are sent 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 | 18 ++++++++++++++++++ src/qmux_http.c | 13 ------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/h3.c b/src/h3.c index fdad3b068..e0a1233d5 100644 --- 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; diff --git a/src/qmux_http.c b/src/qmux_http.c index 9a310a397..552e16821 100644 --- a/src/qmux_http.c +++ b/src/qmux_http.c @@ -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;