]> git.kaiwu.me - haproxy.git/commitdiff
MEDIUM: h1: switch to the generic trailers parser
authorWilly Tarreau <w@1wt.eu>
Wed, 9 Sep 2026 11:40:52 +0000 (13:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 11 Sep 2026 08:08:12 +0000 (10:08 +0200)
Let's now use http_trailers_to_htx() instead of htx_add_all_trailers()
to parse HTTP/1 trailers. Upper case is permitted and thats the only
difference with H2/H3 for now.

The parser is stricter than the previous function, so the following
names are now rejected as it is for other versions:

  "host", "content-length", "connection", "proxy-connection"
  "keep-alive", "upgrade", "te", "transfer-encoding"

src/h1_htx.c

index 5b112d2f88a38987d7d1ff8e40b56032abe774dd..5aa3ad4a840dfb6b9e9f2a6bcdbcf1928f1256ed 100644 (file)
@@ -978,6 +978,7 @@ int h1_parse_msg_tlrs(struct h1m *h1m, struct htx *dsthtx,
 {
        struct http_hdr hdrs[global.tune.max_http_hdr];
        struct h1m tlr_h1m;
+       uint parser_flags;
        int ret = 0;
 
        if (b_data(srcbuf) == ofs) {
@@ -1014,7 +1015,10 @@ int h1_parse_msg_tlrs(struct h1m *h1m, struct htx *dsthtx,
                goto output_full;
        }
 
-       if (!htx_add_all_trailers(dsthtx, hdrs))
+       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)
                goto error;
 
        h1m->state = H1_MSG_DONE;