]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: http: add <need_eot> to trailers parsing function
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 28 Oct 2026 15:16:28 +0000 (16:16 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 12 Nov 2026 16:30:08 +0000 (17:30 +0100)
Adds an extra argument to http_trailers_to_htx() to specify if EOT block
is necessary. Most of this times this will be set to true by callers.
However, it is necessary to skip it if caller does not want to report
EOM immediately after.

For now, every parsers set this new argument to true. This will change
for HTTP/3 parser as FIN can be received later.

include/haproxy/http_htx.h
src/h1_htx.c
src/h3.c
src/http_htx.c
src/mux_h2.c

index cfb7bc5cb1d4fe94e5d51e8bb501de3ad7346ec4..a21d022eec799ec48d70f590b1873112f4aa65a1 100644 (file)
@@ -74,7 +74,7 @@ int http_scheme_based_normalize(struct htx *htx);
 void http_cookie_register(struct http_hdr *list, int idx, int *first, int *last);
 int http_cookie_merge(struct htx *htx, struct http_hdr *list, int first);
 
-enum http_parser_status http_trailers_to_htx(struct http_hdr *list, struct htx *htx, uint flags);
+enum http_parser_status http_trailers_to_htx(struct http_hdr *list, int need_eot, struct htx *htx, uint flags);
 
 struct buffer *http_load_errorfile(const char *file, char **errmsg);
 struct buffer *http_load_errormsg(const char *key, const struct ist msg, char **errmsg);
index ae848a54f086a10d3a3530e2be73ace46a164841..f0c0237d1a7de858ef7231a229eeb392bedb1fbb 100644 (file)
@@ -1065,7 +1065,7 @@ int h1_parse_msg_tlrs(struct h1m *h1m, struct htx *dsthtx,
        parser_flags = HTTP_PF_UPCASE_OK;
        parser_flags |= (h1m->flags & H1_MF_RESP) ? HTTP_PF_DIR_RES : 0;
 
-       if (http_trailers_to_htx(hdrs, dsthtx, parser_flags) != HTTP_PRS_SUCCESS)
+       if (http_trailers_to_htx(hdrs, 1, dsthtx, parser_flags) != HTTP_PRS_SUCCESS)
                goto error;
 
        h1m->state = H1_MSG_DONE;
index 167ce9d9b875012813315fdcebee9df1d88bf9da..33fb55b077a4ab62166f705fcc3a5fb0ba95515a 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -1634,7 +1634,7 @@ static ssize_t h3_trailers_to_htx(struct qcs *qcs, const struct buffer *buf,
                goto out;
        }
 
-       prs_status = http_trailers_to_htx(list, htx, (qcs->qcc->flags & QC_CF_IS_BACK) ? HTTP_PF_DIR_RES : 0);
+       prs_status = http_trailers_to_htx(list, 1, htx, (qcs->qcc->flags & QC_CF_IS_BACK) ? HTTP_PF_DIR_RES : 0);
        switch (prs_status) {
        case HTTP_PRS_SUCCESS:
                break;
index 51853655923752af3b08ad34ed5efa3b20f0973c..23a8da2635dd1ca662732d5ffd4e1769e2200998 100644 (file)
@@ -1978,7 +1978,9 @@ int http_cookie_merge(struct htx *htx, struct http_hdr *list, int first)
  * <htx>, and an HTTP_PRS_SUCCESS status code is returned if some bytes were
  * emitted. In case of error, another code is returned, indicating the nature
  * of the problem. The caller must have verified that the message in the buffer
- * is compatible with receipt of trailers. The <flags> is a union of HTTP_PF_*
+ * is compatible with receipt of trailers. If <need_eot> is true, the EOT
+ * block is appended to the HTX message. Caller may want to skip it for now if
+ * EOM reporting needs to be delayed. The <flags> is a union of HTTP_PF_*
  * describing the parser's state and permissions (direction, pseudo-headers,
  * etc).
  *
@@ -1989,7 +1991,7 @@ int http_cookie_merge(struct htx *htx, struct http_hdr *list, int first)
  *   - in all cases except the end of list, v.name and v.len must designate a
  *     valid value.
  */
-enum http_parser_status http_trailers_to_htx(struct http_hdr *list, struct htx *htx, uint flags)
+enum http_parser_status http_trailers_to_htx(struct http_hdr *list, int need_eot, struct htx *htx, uint flags)
 {
        uint32_t data_ofs = htx->data; /* used to rollback on error */
        enum http_parser_status ret = HTTP_PRS_SUCCESS;
@@ -2121,7 +2123,7 @@ enum http_parser_status http_trailers_to_htx(struct http_hdr *list, struct htx *
        }
 
        /* now finalize the trailers block */
-       if (!htx_add_endof(htx, HTX_BLK_EOT)) {
+       if (need_eot && !htx_add_endof(htx, HTX_BLK_EOT)) {
                ret = HTTP_PRS_TOO_LARGE;
                goto fail;
        }
index 1bab63c2aac055ab1ca2173a255ac65f97555426..39fd6cfb4fa73af0c75753a3b087ab9ca7243f2e 100644 (file)
@@ -6605,7 +6605,7 @@ next_frame:
        }
 
        /* Trailers terminate a DATA sequence */
-       prs_status = http_trailers_to_htx(list, htx, (h2c->flags & H2_CF_IS_BACK) ? HTTP_PF_DIR_RES : 0);
+       prs_status = http_trailers_to_htx(list, 1, htx, (h2c->flags & H2_CF_IS_BACK) ? HTTP_PF_DIR_RES : 0);
        if (prs_status != HTTP_PRS_SUCCESS) {
                switch (prs_status) {
                case HTTP_PRS_INV_HNAME: