Skip to content

Commit 2a82563

Browse files
committed
error handling
1 parent ee39ea4 commit 2a82563

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

http_utils.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"encoding/json"
1010
"errors"
1111
"fmt"
12+
"io"
1213
"io/ioutil"
1314
"net"
1415
"net/http"
@@ -134,7 +135,7 @@ func GetRequest(url string, headers []HeaderLine, ignoreTLSErrors bool) (string,
134135

135136
if err != nil {
136137
fmt.Printf("[-] GetRequest failed to construct an HTTP request from URL %s : %s\n", url, err.Error())
137-
return "", req.Response.StatusCode
138+
return "", 999
138139
}
139140

140141
for _, header := range headers {
@@ -147,7 +148,7 @@ func GetRequest(url string, headers []HeaderLine, ignoreTLSErrors bool) (string,
147148
return "", response.StatusCode
148149
}
149150
defer response.Body.Close()
150-
body, _ := ioutil.ReadAll(response.Body)
151+
body, _ := io.ReadAll(response.Body)
151152

152153
return string(body), response.StatusCode
153154
}

0 commit comments

Comments
 (0)