Skip to content

Commit

Permalink
close ping response body
Browse files Browse the repository at this point in the history
  • Loading branch information
3mard authored and r3inbowari committed Dec 25, 2023
1 parent 2b822c0 commit 03d20fb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions speedtest/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import (
"context"
"errors"
"fmt"
"github.com/showwin/speedtest-go/speedtest/tcp"
"io"
"math"
"net/http"
"net/url"
"strconv"
"strings"
"time"

"github.com/showwin/speedtest-go/speedtest/tcp"
)

type (
Expand Down Expand Up @@ -274,9 +276,11 @@ func (s *Server) HTTPPing(
}
for i := 0; i < echoTimes; i++ {
sTime := time.Now()
_, err = s.Context.doer.Do(req)
resp, err := s.Context.doer.Do(req)
endTime := time.Since(sTime)
if err != nil {
io.Copy(io.Discard, resp.Body)

Check failure on line 282 in speedtest/request.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `io.Copy` is not checked (errcheck)
resp.Body.Close()
failTimes++
continue
}
Expand Down

0 comments on commit 03d20fb

Please sign in to comment.