]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: haterm: Add an request option to disable splicing
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 3 Apr 2026 08:26:37 +0000 (10:26 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 3 Apr 2026 08:46:15 +0000 (10:46 +0200)
The parameter "?S=0" can now be added on the request URI to disable the
splicing for the response. "?S=1" will only fallback on the haterm settings.

src/haterm.c

index 77a137e6c2e3f4949872e725cdb3a795685ab5b6..a3b50aec933fd7c93929ed54ed20957ad3b2e1ff 100644 (file)
@@ -33,6 +33,7 @@ DECLARE_TYPED_POOL(pool_head_hstream, "hstream", struct hstream);
 #define HS_ST_OPT_REQ_AFTER_RES 0x0100 /* drain the request payload after the response (?A=1) */
 #define HS_ST_OPT_RANDOM_RES    0x0200 /* random response (?R=1) */
 #define HS_ST_OPT_NO_CACHE      0x0400 /* non-cacheable resposne (?c=0) */
+#define HS_ST_OPT_NO_SPLICING   0x0800 /* no splicing (?S=1) */
 
 const char *HTTP_HELP =
        "HAProxy's dummy HTTP server for benchmarks - version " HAPROXY_VERSION ".\n"
@@ -52,7 +53,7 @@ const char *HTTP_HELP =
         "                     E.g. /?K=1\n"
         " - /?t=<time>        wait <time> milliseconds before responding.\n"
         "                     E.g. /?t=500\n"
-        " - /?k=<enable>      Enable transfer encoding chunked with only one chunk if >0.\n"
+        " - /?k=<enable>      Enable transfer encoding chunked with only one chunk if >0 (disable fast-forward and splicing).\n"
         " - /?S=<enable>      Disable use of splice() to send data if <1.\n"
         " - /?R=<enable>      Enable sending random data if >0.\n"
         "\n"
@@ -330,7 +331,9 @@ static int hstream_ff_snd(struct connection *conn, struct hstream *hs)
 
        nego_flags |= NEGO_FF_FL_EXACT_SIZE;
 #if defined(USE_LINUX_SPLICE)
-       if ((global.tune.options & GTUNE_USE_SPLICE) && !(sd->iobuf.flags & IOBUF_FL_NO_SPLICING))
+       if ((global.tune.options & GTUNE_USE_SPLICE) &&
+           !(sd->iobuf.flags & IOBUF_FL_NO_SPLICING) &&
+           !(hs->flags & HS_ST_OPT_NO_SPLICING))
                nego_flags |= NEGO_FF_FL_MAY_SPLICE;
 #endif
        len = se_nego_ff(sd, &BUF_NULL, hs->to_write, nego_flags);
@@ -820,6 +823,12 @@ static void hstream_parse_uri(struct ist uri, struct hstream *hs)
                                        else
                                                hs->flags &= ~HS_ST_OPT_CHUNK_RES;
                                        break;
+                               case 'S':
+                                       if (result < 1)
+                                               hs->flags |= HS_ST_OPT_NO_SPLICING;
+                                       else
+                                               hs->flags &= ~HS_ST_OPT_NO_SPLICING;
+                                       break;
                                case 'R':
                                        if (result > 0)
                                                hs->flags |= HS_ST_OPT_RANDOM_RES;