From: Amaury Denoyelle Date: Wed, 11 Jun 2025 09:45:40 +0000 (+0200) Subject: MINOR: hq-interop: encode request from HTX for backend side support X-Git-Tag: v3.3-dev2~65 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=603afd495bed8225a91109ba0f465188b91f1e48;p=thirdparty%2Fhaproxy.git MINOR: hq-interop: encode request from HTX for backend side support Implement transcoding of a HTX request into HTTP/0.9. This protocol is a simplified version of HTTP. Request only supports GET method without any header. As such, only a request line is written during snd_buf operation. --- diff --git a/src/hq_interop.c b/src/hq_interop.c index 46a456ef1..77f3518fd 100644 --- a/src/hq_interop.c +++ b/src/hq_interop.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -160,6 +161,7 @@ static size_t hq_interop_snd_buf(struct qcs *qcs, struct buffer *buf, enum htx_blk_type btype; struct htx *htx = NULL; struct htx_blk *blk; + struct htx_sl *sl = NULL; int32_t idx; uint32_t bsize, fsize; struct buffer *res = NULL; @@ -175,9 +177,25 @@ static size_t hq_interop_snd_buf(struct qcs *qcs, struct buffer *buf, btype = htx_get_blk_type(blk); fsize = bsize = htx_get_blksz(blk); - BUG_ON(btype == HTX_BLK_REQ_SL); - switch (btype) { + case HTX_BLK_REQ_SL: + res = qcc_get_stream_txbuf(qcs, &err, 0); + if (!res) { + BUG_ON(err); /* TODO */ + goto end; + } + + BUG_ON_HOT(sl); /* Only one start-line expected */ + sl = htx_get_blk_ptr(htx, blk); + + /* Only GET supported for HTTP/0.9. */ + b_putist(res, ist("GET ")); + b_putist(res, htx_sl_req_uri(sl)); + b_putist(res, ist(" HTTP/0.9\r\n")); + htx_remove_blk(htx, blk); + total += fsize; + break; + case HTX_BLK_DATA: res = qcc_get_stream_txbuf(qcs, &err, 0); if (!res) {