From: Willy Tarreau Date: Tue, 22 Sep 2026 20:09:16 +0000 (+0000) Subject: REGTESTS: sample_fetches: test res.body, res.body_len and server_status X-Git-Tag: v3.5-dev8~19 X-Git-Url: https://git.kaiwu.me/$%7BISSUES%7D/static/gitweb.js?a=commitdiff_plain;h=0cd2678d371dfa98cb46632829a84a0b4b9f06f2;p=haproxy.git REGTESTS: sample_fetches: test res.body, res.body_len and server_status 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. --- diff --git a/reg-tests/sample_fetches/http_response.vtc b/reg-tests/sample_fetches/http_response.vtc index a7bff474e..ddc912a6e 100644 --- a/reg-tests/sample_fetches/http_response.vtc +++ b/reg-tests/sample_fetches/http_response.vtc @@ -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"