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.
This commit is contained in:
Amaury Denoyelle 2025-05-30 16:25:15 +02:00
parent 235e818fa1
commit 96183abfbd
2 changed files with 12 additions and 3 deletions

View File

@ -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 */

View 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;
}
}