]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http-ana: Use HTX API to move to a large buffer
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 10 Mar 2026 07:11:35 +0000 (08:11 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 23 Mar 2026 13:02:42 +0000 (14:02 +0100)
Use htx_move_to_large_buffer() to move a regular HTX message to a large
buffer when we are waiting for a huge payload.

src/http_ana.c

index 51d53b3ed517a19b6de3d78e9786f6756183e4c0..80726e9f6c5d879752f0e05797edaffb15bd9417 100644 (file)
@@ -4337,20 +4337,10 @@ enum rule_result http_wait_for_msg_body(struct stream *s, struct channel *chn,
        }
 
        if (channel_htx_full(chn, htx, global.tune.maxrewrite) || sc_waiting_room(chn_prod(chn))) {
-               struct buffer lbuf;
-               char *area;
+               struct buffer lbuf = BUF_NULL;
 
-               if (large_buffer == 0 || b_is_large(&chn->buf))
-                       goto end; /* don't use large buffer or large buffer is full */
-
-               /* normal buffer is full, allocate a large one
-                */
-               area = pool_alloc(pool_head_large_buffer);
-               if (!area)
-                       goto end; /* Allocation failure: TODO must be improved to use buffer_wait */
-               lbuf = b_make(area, global.tune.bufsize_large, 0, 0);
-               htx_xfer_blks(htx_from_buf(&lbuf), htx, htx_used_space(htx), HTX_BLK_UNUSED);
-               htx_to_buf(htx, &chn->buf);
+               if (large_buffer == 0 || b_is_large(&chn->buf) || !htx_move_to_large_buffer(&lbuf, &chn->buf))
+                       goto end; /* don't use large buffer or already a large buffer */
                b_free(&chn->buf);
                offer_buffers(s, 1);
                chn->buf = lbuf;