From b007b7aa0413067edc38cbb13eee1942f46d5989 Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Wed, 11 Feb 2026 15:11:27 +0100 Subject: [PATCH] MINOR: haterm: new "haterm" utility haterm_init.c is added to implement haproxy_init_args() which overloads the one defined by haproxy.c. This way, haterm program uses its own argv[] parsing function. It generates its own configuration in memory that is parsed during boot and executed by the common code. --- Makefile | 6 + doc/haterm.txt | 135 ++++++++++++++++ src/haterm.c | 4 +- src/haterm_init.c | 384 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 527 insertions(+), 2 deletions(-) create mode 100644 doc/haterm.txt create mode 100644 src/haterm_init.c diff --git a/Makefile b/Makefile index da50e2625..d4d9a57f4 100644 --- a/Makefile +++ b/Makefile @@ -956,6 +956,7 @@ endif # obsolete targets endif # TARGET OBJS = +HATERM_OBJS = ifneq ($(EXTRA_OBJS),) OBJS += $(EXTRA_OBJS) @@ -1009,6 +1010,8 @@ ifneq ($(TRACE),) OBJS += src/calltrace.o endif +HATERM_OBJS += $(OBJS) src/haterm_init.o + # Used only for forced dependency checking. May be cleared during development. INCLUDES = $(wildcard include/*/*.h) DEP = $(INCLUDES) .build_opts @@ -1056,6 +1059,9 @@ endif # non-empty target haproxy: $(OPTIONS_OBJS) $(OBJS) $(cmd_LD) $(ARCH_FLAGS) $(LDFLAGS) -o $@ $^ $(LDOPTS) +haterm: $(OPTIONS_OBJS) $(HATERM_OBJS) + $(cmd_LD) $(ARCH_FLAGS) $(LDFLAGS) -o $@ $^ $(LDOPTS) + objsize: haproxy $(Q)objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort diff --git a/doc/haterm.txt b/doc/haterm.txt new file mode 100644 index 000000000..fbc58b9ee --- /dev/null +++ b/doc/haterm.txt @@ -0,0 +1,135 @@ + ------ + HATerm + ------ + HAProxy's dummy HTTP + server for benchmarks + +1. Background +------------- + +HATerm is a dummy HTTP server that leverages the flexible and scalable +architecture of HAProxy to ease benchmarking of HTTP agents in all versions of +HTTP currently supported by HAProxy (HTTP/1, HTTP/2, HTTP/3), and both in clear +and TLS / QUIC. It follows the same principle as its ancestor HTTPTerm [1], +consisting in producing HTTP responses entirely configured by the request +parameters (size, response time, status etc). It also preserves the spirit +HTTPTerm which does not require any configuration beyond an optional listening +address and a port number, though it also supports advanced configurations with +the full spectrum of HAProxy features for specific testing. The goal remains +to make it almost as fast as the original HTTPTerm so that it can become a +de-facto replacement, with a compatible command line and request parameters +that will not change users' habits. + + [1] https://github.com/wtarreau/httpterm + + +2. Compilation +-------------- + +HATerm may be compiled in the same way as HAProxy but with "haterm" as Makefile +target to provide on the "make" command line as follows: + + $ make -j $(nproc) TARGET=linux-glibc haterm + +HATerm supports HTTPS/SSL/TCP: + + $ make TARGET=linux-glibc USE_OPENSSL=1 + +It also supports QUIC: + + $ make -j $(nproc) TARGET=linux-glibc USE_OPENSSL=1 USE_QUIC=1 haterm + +Technically speaking, it uses the regular HAProxy source and object code with a +different command line parser. As such, all build options supported by HAProxy +also apply to HATerm. See INSTALL for more details about how to compile them. + + +3. Execution +------------ + +HATerm is a very easy to use HTTP server with supports for all the HTTP +versions. It displays its usage when run without argument or wrong arguments: + + $ ./haterm + Usage : haterm -L []:[:] [-L...]* [opts] + where may be any combination of: + -G : multiple option; append to the "global" section + -F : multiple option; append to the "frontend" section + -T : multiple option; append to the "traces" section + -C : dump the configuration and exit + -D : goes daemon + -v : shows version + -d : enable the traces for all http protocols + +Arguments -G, -F, -T permit to append one or multiple lines at the end of their +respective sections. A tab character ('\t') is prepended at the beginning of +the argument, and a line feed ('\n') is appended at the end. It is also +possible to insert multiple lines at once using escape sequences '\n' and '\t' +inside the string argument. + +As HAProxy, HATerm may listen on several TCP/UDP addresses which can be +provided by multiple "-L" options. To be functional, it needs at least one +correct "-L" option to be set. + +Examples: + + $ ./haterm -L 127.0.0.1:8888 # listen on 127.0.0.1:8888 TCP address + + $ ./haterm -L 127.0.0.1:8888:8889 # listen on 127.0.0.1:8888 TCP address, + # 127.0.01:8889 SSL/TCP address, + # and 127.0.01:8889 QUIC/UDP address + + $ ./haterm -L 127.0.0.1:8888:8889 -L [::1]:8888:8889 + +With USE_QUIC_OPENSSL_COMPAT support, the user must configure a global +section as for HAProxy. HATerm sets internally its configuration in. +memory as this is done by HAProxy from configuration files: + + $ ./haterm -L 127.0.0.1:8888:8889 + [NOTICE] (1371578) : haproxy version is 3.4-dev4-ba5eab-28 + [NOTICE] (1371578) : path to executable is ./haterm + [ALERT] (1371578) : Binding [haterm cfgfile:12] for frontend + ___haterm_frontend___: this SSL library does not + support the QUIC protocol. A limited compatibility + layer may be enabled using the "limited-quic" global + option if desired. + +Such an alert may be fixed with "-G' option: + + $ ./haterm -L 127.0.0.1:8888:8889 -G "limited-quic" + + +When the SSL support is not compiled in, the second port is ignored. This is +also the case for the QUIC support. + +HATerm adjusts its responses depending on the requests it receives. An empty +query string provides the information about how the URIs are understood by +HATerm: + + $ curl http://127.0.0.1:8888/? + HAProxy's dummy HTTP server for benchmarks - version 3.4-dev4. + All integer argument values are in the form [digits]*[kmgr] (r=random(0..1)) + The following arguments are supported to override the default objects : + - /?s= return bytes. + E.g. /?s=20k + - /?r= present as the HTTP return code. + E.g. /?r=404 + - /?c= set the return as not cacheable if <1. + E.g. /?c=0 + - /?A= drain the request body after sending the response. + E.g. /?A=1 + - /?C= force the response to use close if >0. + E.g. /?C=1 + - /?K= force the response to use keep-alive if >0. + E.g. /?K=1 + - /?t=