From: Amaury Denoyelle Date: Fri, 30 May 2025 14:25:15 +0000 (+0200) Subject: MINOR: h3: adjust path request encoding X-Git-Tag: v3.3-dev2~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=96183abfbd29dca698300078b85aa3647601b807;p=thirdparty%2Fhaproxy.git MINOR: h3: adjust path request encoding 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. --- diff --git a/src/h3.c b/src/h3.c index 2eb9360ca..41d9250b1 100644 --- 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 */ diff --git a/src/qpack-enc.c b/src/qpack-enc.c index ba03b7042..5f4694979 100644 --- a/src/qpack-enc.c +++ b/src/qpack-enc.c @@ -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; } }