fix: url test http response not closed

This commit is contained in:
Skyxim 2022-06-19 17:29:46 +08:00
parent c1a99b9be4
commit 109a76e1fc

View File

@ -156,20 +156,27 @@ func (p *Proxy) URLTest(ctx context.Context, url string) (t uint16, err error) {
return http.ErrUseLastResponse
},
}
defer client.CloseIdleConnections()
resp, err := client.Do(req)
if err != nil {
return
}
_ = resp.Body.Close()
if unifiedDelay {
start = time.Now()
resp, err = client.Do(req)
respRepeat, err := client.Do(req)
if err != nil {
return
return 0, err
}
_ = respRepeat.Body.Close()
}
_ = resp.Body.Close()
t = uint16(time.Since(start) / time.Millisecond)
return
}