Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
JayBeale committed May 14, 2024
1 parent ee39ea4 commit 2a82563
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions http_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down

0 comments on commit 2a82563

Please sign in to comment.