about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-11-02 22:48:17 +0100
committerEmile <hanemile@protonmail.com>2019-11-02 22:48:17 +0100
commit963543b000b16e7d95958ea97bbdc4a9abadb407 (patch)
tree63ecee3284a4b778e504059ba495863a1e04fd0b
parent1ebff74874b295757f18249169ed411f0c48b645 (diff)
return the http info (lines, words, chars, ...)
-rw-r--r--src/httpRequest.go19
1 files changed, 17 insertions, 2 deletions
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