From: Frederic Lecaille Date: Thu, 19 Nov 2026 09:53:40 +0000 (+0100) Subject: REGTESTS: protobuf: cover the gRPC message compression flag X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/gitweb.js?a=commitdiff_plain;h=e1b6bc97c812a80cbf785d0ce49466bf1fdd6535;p=haproxy.git REGTESTS: protobuf: cover the gRPC message compression flag Regression test for "BUG/MINOR: sample: do not parse compressed gRPC messages in ungrpc". Two bodies are added to the frontend which already walks a body of two gRPC messages: - "01 00000005 0a03616161 00 00000002 1007" flags the first message compressed. Its payload must not be parsed, so x-g1 stays empty instead of reading "aaa". x-g2 must still find 7 in the second message, which checks the skip resumes on a message boundary. - "02 00000002 1007" sets an invalid flag, so the walk must stop and x-g2 must stay empty. A failing expect aborts the script, so the second body is only observed after the fix, not before it. --- diff --git a/reg-tests/protobuf/grpc.vtc b/reg-tests/protobuf/grpc.vtc index 095378c74..6595a2878 100644 --- a/reg-tests/protobuf/grpc.vtc +++ b/reg-tests/protobuf/grpc.vtc @@ -232,3 +232,32 @@ client c3 -connect ${h1_fe3_sock} { expect resp.http.x-g2 == "7" expect resp.http.x-g3 == "" } -run + +# The first message is flagged compressed. HAProxy does not decompress, so +# its payload must not be handed to the protobuf parser: "0a03616161" would +# otherwise read as field 1 = "aaa", a value that only exists after +# decompression. The converter skips it and reaches field 2 of the second, +# uncompressed message. +client c4 -connect ${h1_fe3_sock} { + txreq -req POST -url "/" -hdr "content-length: 17" \ + -hdr "grpc-encoding: gzip" -nolen + sendhex "01 00000005 0a03616161 00 00000002 1007" + rxresp + expect resp.status == 200 + expect resp.http.x-g1 == "" + expect resp.http.x-g2 == "7" + expect resp.http.x-g3 == "" +} -run + +# The Compressed-Flag may only be 0 or 1. 02 makes the framing invalid, so +# the walk stops instead of parsing the payload: field 2 = 7 must not be +# reported. +client c5 -connect ${h1_fe3_sock} { + txreq -req POST -url "/" -hdr "content-length: 7" -nolen + sendhex "02 00000002 1007" + rxresp + expect resp.status == 200 + expect resp.http.x-g1 == "" + expect resp.http.x-g2 == "" + expect resp.http.x-g3 == "" +} -run