]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h3: adjust path request encoding
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 30 May 2025 14:25:15 +0000 (16:25 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 16 Jun 2025 16:11:09 +0000 (18:11 +0200)
Previously, HTTP/3 backend request :path was hardcoded to value '/'.
Change this so that we can now encode any path as requested by the
client. Path is extracted from the HTX URI. Also, qpack_encode_path() is
extended to support literal field line with name ref.

src/h3.c
src/qpack-enc.c

index 2eb9360ca67cb6af8a959007cf624474364d680d..41d9250b1baffa52427fc7d21cd83de60e1796c7 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -1794,7 +1794,7 @@ static int h3_req_headers_send(struct qcs *qcs, struct htx *htx)
        if (qpack_encode_scheme(&headers_buf, scheme))
                goto err;
 
-       if (qpack_encode_path(&headers_buf, ist('/')))
+       if (qpack_encode_path(&headers_buf, uri))
                goto err;
 
        /* :authority */
index ba03b7042d40963e707fc992c92e5937d3c3b41c..5f4694979654dbd87eefe64cf3195bcb3e0ceaed 100644 (file)
@@ -206,6 +206,8 @@ int qpack_encode_scheme(struct buffer *out, const struct ist scheme)
 /* Returns 0 on success else non-zero. */
 int qpack_encode_path(struct buffer *out, const struct ist path)
 {
+       size_t sz;
+
        if (unlikely(isteq(path, ist("/")))) {
                if (!b_room(out))
                        return 1;
@@ -214,8 +216,15 @@ int qpack_encode_path(struct buffer *out, const struct ist path)
                return 0;
        }
        else {
-               /* TODO */
-               ABORT_NOW();
+               sz = 1 + qpack_get_prefix_int_size(istlen(path), 7) + istlen(path);
+               if (b_room(out) < sz)
+                       return 1;
+
+               qpack_encode_prefix_integer(out, 1, 4, 0x50);
+               qpack_encode_prefix_integer(out, istlen(path), 7, 0);
+               for (size_t i = 0; i < istlen(path); ++i)
+                       b_putchr(out, istptr(path)[i]);
+               return 0;
        }
 }