From 2a825637daa43e568f4d89668ea146ae4f88b4a5 Mon Sep 17 00:00:00 2001 From: Jay Beale Date: Tue, 14 May 2024 14:17:12 -0700 Subject: [PATCH] error handling --- http_utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/http_utils.go b/http_utils.go index 2af67aa..44cb202 100644 --- a/http_utils.go +++ b/http_utils.go @@ -9,6 +9,7 @@ import ( "encoding/json" "errors" "fmt" + "io" "io/ioutil" "net" "net/http" @@ -134,7 +135,7 @@ func GetRequest(url string, headers []HeaderLine, ignoreTLSErrors bool) (string, if err != nil { fmt.Printf("[-] GetRequest failed to construct an HTTP request from URL %s : %s\n", url, err.Error()) - return "", req.Response.StatusCode + return "", 999 } for _, header := range headers { @@ -147,7 +148,7 @@ func GetRequest(url string, headers []HeaderLine, ignoreTLSErrors bool) (string, return "", response.StatusCode } defer response.Body.Close() - body, _ := ioutil.ReadAll(response.Body) + body, _ := io.ReadAll(response.Body) return string(body), response.StatusCode }