Fix HTTP response body not being closed properly

This commit is contained in:
naiba 2023-12-05 23:21:56 +08:00
parent 793dafcd80
commit abf3a7150b

View File

@ -405,6 +405,10 @@ func handleHttpGetTask(task *pb.Task, result *pb.TaskResult) {
}
func checkHttpResp(taskUrl string, start time.Time, resp *http.Response, err error, result *pb.TaskResult) {
if err == nil {
defer resp.Body.Close()
_, err = io.Copy(io.Discard, resp.Body)
}
if err == nil {
// 检查 HTTP Response 状态
result.Delay = float32(time.Since(start).Microseconds()) / 1000.0