From 404ef1de281c4907e2863236da49602d95d0c0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Wed, 13 Mar 2024 17:54:05 +0300 Subject: [PATCH 1/2] do not omit content length --- runner/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runner/types.go b/runner/types.go index 37b98c0d..36fdc3b2 100644 --- a/runner/types.go +++ b/runner/types.go @@ -73,7 +73,7 @@ type Result struct { Words int `json:"words" csv:"words"` Lines int `json:"lines" csv:"lines"` StatusCode int `json:"status_code,omitempty" csv:"status_code"` - ContentLength int `json:"content_length,omitempty" csv:"content_length"` + ContentLength int `json:"content_length" csv:"content_length"` Failed bool `json:"failed" csv:"failed"` VHost bool `json:"vhost,omitempty" csv:"vhost"` WebSocket bool `json:"websocket,omitempty" csv:"websocket"` From 3fe1ea70f52ba77be7591dd48f9d79d358954810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Wed, 13 Mar 2024 17:54:12 +0300 Subject: [PATCH 2/2] fix words and lines len --- common/httpx/httpx.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/httpx/httpx.go b/common/httpx/httpx.go index 0a322079..68c70f7a 100644 --- a/common/httpx/httpx.go +++ b/common/httpx/httpx.go @@ -288,10 +288,12 @@ get_response: // fill metrics resp.StatusCode = httpresp.StatusCode - // number of words - resp.Words = len(strings.Split(respbodystr, " ")) - // number of lines - resp.Lines = len(strings.Split(respbodystr, "\n")) + if respbodystr != "" { + // number of words + resp.Words = len(strings.Split(respbodystr, " ")) + // number of lines + resp.Lines = len(strings.Split(strings.TrimSpace(respbodystr), "\n")) + } if !h.Options.Unsafe && h.Options.TLSGrab { if h.Options.ZTLS {