From 3ab5044c1c3b1baa006e5ed3df2416d3d14ea22c Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 3 Apr 2026 10:17:39 +0200 Subject: [PATCH] MINOR: haterm: Handle boolean request options as flags Following request options are now handled as flags: - ?k=1 => flag HS_ST_OPT_CHUNK_RES is set - ?c=0 => flag HS_ST_OPT_NO_CACHE is set - ?R=1 => flag HS_ST_OPT_RANDOM_RES is set - ?A=A => flag HS_ST_OPT_REQ_AFTER_RES is set. By default, none is set. --- include/haproxy/hstream-t.h | 4 --- src/haterm.c | 68 +++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/include/haproxy/hstream-t.h b/include/haproxy/hstream-t.h index e9ef52a20..2eae26a60 100644 --- a/include/haproxy/hstream-t.h +++ b/include/haproxy/hstream-t.h @@ -21,15 +21,11 @@ struct hstream { int flags; int ka; /* .0: keep-alive .1: forced .2: http/1.1, .3: was_reused */ - int req_cache; unsigned long long req_size; /* values passed in the URI to override the server's */ unsigned long long req_body; /* remaining body to be consumed from the request */ int req_code; int res_wait; /* time to wait before replying in ms */ int res_time; - int req_chunked; - int req_random; - int req_after_res; /* Drain the request body after having sent the response */ enum http_meth_t req_meth; }; diff --git a/src/haterm.c b/src/haterm.c index f7ef4ddbe..77a137e6c 100644 --- a/src/haterm.c +++ b/src/haterm.c @@ -29,6 +29,10 @@ DECLARE_TYPED_POOL(pool_head_hstream, "hstream", struct hstream); #define HS_ST_HTTP_HELP 0x0010 #define HS_ST_HTTP_EXPECT 0x0020 #define HS_ST_HTTP_RESP_SL_SENT 0x0040 +#define HS_ST_OPT_CHUNK_RES 0x0080 /* chunk-encoded response (?k=1) */ +#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) */ const char *HTTP_HELP = "HAProxy's dummy HTTP server for benchmarks - version " HAPROXY_VERSION ".\n" @@ -48,7 +52,7 @@ const char *HTTP_HELP = " E.g. /?K=1\n" " - /?t=