Skip to content

Commit

Permalink
Fix HTTP response body not being closed properly
Browse files Browse the repository at this point in the history
  • Loading branch information
naiba committed Dec 5, 2023
1 parent 793dafc commit abf3a71
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit abf3a71

Please sign in to comment.