From 67fb276a76c14f51339cf31e760147da84786117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Senart?= Date: Mon, 9 Sep 2013 03:04:33 +0100 Subject: [PATCH] Use actual body length for BytesIn --- lib/attack.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/attack.go b/lib/attack.go index 84d6d80..dc15a0c 100644 --- a/lib/attack.go +++ b/lib/attack.go @@ -73,9 +73,13 @@ func hit(req *http.Request, res chan Result) { Error: err, } if err == nil { - result.BytesIn, result.Code = uint64(r.ContentLength), uint64(r.StatusCode) - if body, err := ioutil.ReadAll(r.Body); err != nil && (result.Code < 200 || result.Code >= 300) { - result.Error = errors.New(string(body)) + result.Code = uint64(r.StatusCode) + if body, err := ioutil.ReadAll(r.Body); err != nil { + if result.Code < 200 || result.Code >= 300 { + result.Error = errors.New(string(body)) + } + } else { + result.BytesIn = uint64(len(body)) } } res <- result