]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hq-interop: encode request from HTX for backend side support
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 11 Jun 2025 09:45:40 +0000 (11:45 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 12 Jun 2025 09:28:54 +0000 (11:28 +0200)
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.

src/hq_interop.c

index 46a456ef1d81f043ede0afbd38d9ec37f3a54e3a..77f3518fd1f095b581a3db50fb974bb4c03ddd38 100644 (file)
@@ -6,6 +6,7 @@
 #include <haproxy/dynbuf.h>
 #include <haproxy/htx.h>
 #include <haproxy/http.h>
+#include <haproxy/istbuf.h>
 #include <haproxy/mux_quic.h>
 #include <haproxy/qmux_http.h>
 #include <haproxy/qmux_trace.h>
@@ -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) {