]> git.kaiwu.me - haproxy.git/commitdiff
REGTESTS: sample_fetches: test res.body, res.body_len and server_status
authorWilly Tarreau <w@1wt.eu>
Tue, 22 Sep 2026 20:09:16 +0000 (20:09 +0000)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 15:25:37 +0000 (17:25 +0200)
The response test covered res.body_size but neither the body itself nor
its length, and not the status as it was received from the server. The
two body fetches only see what has already been received, so an
"http-response wait-for-body" is added in front of them to make the
result deterministic.

reg-tests/sample_fetches/http_response.vtc

index a7bff474e26a20bdd2a2cdd680bd8fbed508f07e..ddc912a6ee8de1d10a21f9a4a46fadea3854ccbd 100644 (file)
@@ -38,6 +38,10 @@ haproxy h1 -conf {
        bind "fd@${fe}"
        capture response header x-num len 16
 
+       # res.body and res.body_len only see what has already been received,
+       # which wait-for-body makes deterministic here
+       http-response wait-for-body time "${HAPROXY_TEST_TIMEOUT-5s}"
+
        http-response set-header x-status    "%[status]"
        http-response set-header x-txnstatus "%[txn.status]"
        http-response set-header x-ver        "%[res.ver]"
@@ -75,6 +79,11 @@ haproxy h1 -conf {
        http-response set-header x-cooknames  "%[res.cook_names]"
 
        http-response set-header x-bodysize   "%[res.body_size]"
+       http-response set-header x-body       "%[res.body]"
+       http-response set-header x-bodylen    "%[res.body_len]"
+
+       # the status as it was received from the server, before any rewrite
+       http-response set-header x-srvstatus  "%[server_status]"
 
        # the pre-parsed header block must carry the lowercase header names
        # and their values, here "x-num" and "42"
@@ -136,6 +145,9 @@ client c1 -connect ${h1_fe_sock} {
        expect resp.http.x-cooknames == "c1,c2,path"
 
        expect resp.http.x-bodysize  == "5"
+       expect resp.http.x-body      == "hello"
+       expect resp.http.x-bodylen   == "5"
+       expect resp.http.x-srvstatus == "201"
 
        expect resp.http.x-hdrsbin   ~  "782d6e756d023432"
        expect resp.http.x-hdrs      == "yes"