From 963543b000b16e7d95958ea97bbdc4a9abadb407 Mon Sep 17 00:00:00 2001 From: Emile Date: Sat, 2 Nov 2019 22:48:17 +0100 Subject: return the http info (lines, words, chars, ...) --- src/httpRequest.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/httpRequest.go') diff --git a/src/httpRequest.go b/src/httpRequest.go index 139e0a4..9ad8f9a 100644 --- a/src/httpRequest.go +++ b/src/httpRequest.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "io/ioutil" "log" "net/http" "strings" @@ -19,10 +20,24 @@ func httpRequest(channels channels, threadNr int) { if err != nil { log.Println(err) } else { + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + + if err != nil { + log.Println(err) + } + + responseLines := len(strings.Split(string(body), "\n")) - 1 + responseWords := len(strings.Split(string(body), " ")) + responseChars := len(string(body)) + // define the response var response = Response{ - StatusCode: resp.StatusCode, - FuzzWord: fuzzWord, + StatusCode: resp.StatusCode, + ResponseLines: responseLines, + ResponseWords: responseWords, + ResponseChars: responseChars, + FuzzWord: fuzzWord, } // insert the response into the print channel for further printing -- cgit 1.4.1