Remove deadline check

This commit is contained in:
Ben Sarmiento
2024-01-26 18:37:20 +01:00
parent 70f3516cac
commit d42ac347cf

View File

@@ -194,19 +194,7 @@ func (r *HTTPClient) Do(req *http.Request) (*http.Response, error) {
for { for {
r.replaceHostIfNeeded(req) r.replaceHostIfNeeded(req)
ctx, cancel := context.WithTimeout(req.Context(), time.Duration(r.timeoutSecs)*time.Second)
defer cancel()
req = req.WithContext(ctx)
resp, err = r.client.Do(req) resp, err = r.client.Do(req)
select {
case <-ctx.Done():
if ctx.Err() == context.DeadlineExceeded {
err = fmt.Errorf("request timed out after %d seconds", r.timeoutSecs)
}
default:
}
if resp != nil && (resp.StatusCode < http.StatusOK || resp.StatusCode > http.StatusPartialContent) { if resp != nil && (resp.StatusCode < http.StatusOK || resp.StatusCode > http.StatusPartialContent) {
body, _ := io.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
if body != nil { if body != nil {