@@ -285,7 +285,6 @@ func (pt *PerfTest) runVegetaAttack(ctx context.Context, targets []vegeta.Target
285285
286286 timeout , _ := time .ParseDuration (pt .Config .VegetaResponseTimeout )
287287 maxConnInt , _ := strconv .Atoi (pt .Config .MaxConnection )
288- maxBodyInt , _ := strconv .Atoi (pt .Config .MaxBodyRsp )
289288
290289 tr := & http.Transport {
291290 DisableCompression : pt .Config .DisableHttpCompression ,
@@ -299,14 +298,21 @@ func (pt *PerfTest) runVegetaAttack(ctx context.Context, targets []vegeta.Target
299298 Transport : tr ,
300299 }
301300
301+ // Vegeta v12 reads MaxBody bytes then drains the remainder with
302+ // io.Copy(io.Discard, r.Body). If the drain fails (e.g. server RST on a
303+ // keepalive connection), res.Code stays 0 and the request is counted as
304+ // failed even though a 200 OK was received.
305+ // With MaxBody(-1) Vegeta reads the full body; the drain is then a no-op
306+ // (0 bytes remaining), res.Code is always set correctly, and success
307+ // counting matches Python/vegeta-CLI behaviour.
302308 //
303- // High workers() counts can saturate server resources
309+ // High workers() counts can saturate server resources.
304310 //
305311 attacker := vegeta .NewAttacker (
306312 vegeta .Client (customClient ),
307313 vegeta .Timeout (timeout ),
308- vegeta .Workers (vegeta .DefaultWorkers ),
309- vegeta .MaxBody (int64 ( maxBodyInt ) ),
314+ vegeta .Workers (vegeta .DefaultWorkers ),
315+ vegeta .MaxBody (- 1 ),
310316 vegeta .KeepAlive (true ),
311317 )
312318
0 commit comments