]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: h3: concatenate multiple cookie headers
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 17 Aug 2022 16:02:47 +0000 (18:02 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 18 Aug 2022 14:13:33 +0000 (16:13 +0200)
As specified by RFC 9114, multiple cookie headers must be concatenated
into a single entry before passing it to a HTTP/1.1 connection. To
implement this, reuse the same function as already used for HTTP/2
module.

This should answer to feature requested in github issue #1818.

src/h3.c

index ea24fe8cd75b5955d6a14a2cd08533ee089d2740..53372c5e3ec9e9638f6139001c073c3bb10fbb0c 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -22,6 +22,7 @@
 #include <haproxy/h3.h>
 #include <haproxy/h3_stats.h>
 #include <haproxy/http.h>
+#include <haproxy/http_htx.h>
 #include <haproxy/htx.h>
 #include <haproxy/intops.h>
 #include <haproxy/istbuf.h>
@@ -346,6 +347,7 @@ static ssize_t h3_headers_to_htx(struct qcs *qcs, const struct buffer *buf,
        //struct ist scheme = IST_NULL, authority = IST_NULL;
        struct ist authority = IST_NULL;
        int hdr_idx, ret;
+       int cookie = -1, last_cookie = -1;
 
        TRACE_ENTER(H3_EV_RX_FRAME|H3_EV_RX_HDR, qcs->qcc->conn, qcs);
 
@@ -409,12 +411,24 @@ static ssize_t h3_headers_to_htx(struct qcs *qcs, const struct buffer *buf,
                if (isteq(list[hdr_idx].n, ist("")))
                        break;
 
+               if (isteq(list[hdr_idx].n, ist("cookie"))) {
+                       http_cookie_register(list, hdr_idx, &cookie, &last_cookie);
+                       continue;
+               }
+
                if (!istmatch(list[hdr_idx].n, ist(":")))
                        htx_add_header(htx, list[hdr_idx].n, list[hdr_idx].v);
 
                ++hdr_idx;
        }
 
+       if (cookie >= 0) {
+               if (http_cookie_merge(htx, list, cookie)) {
+                       h3c->err = H3_INTERNAL_ERROR;
+                       return -1;
+               }
+       }
+
        htx_add_endof(htx, HTX_BLK_EOH);
        htx_to_buf(htx, &htx_buf);