mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2026-12-02 09:13:21 +00:00
Handle error on response body close to prevent panic
This commit is contained in:
1 parent
dea2f7bf45
commit
3a09d28ea3
1 file changed
+4
-1
+4
-1
@@ -133,7 +133,10 @@ func checkLatency(domain string, ip string, port string) {
|
||||
// 防止后续对 nil Body 的读写导致 panic
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func() {
|
||||
// 明确忽略关闭时的错误,HTTP 客户端此时已经读完正文
|
||||
_ = resp.Body.Close()
|
||||
}()
|
||||
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user