Skip to content

Commit

Permalink
Replace deprecated ioutil calls
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Aug 29, 2023
1 parent 2715d97 commit eb0328d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"time"

Expand Down Expand Up @@ -38,14 +38,14 @@ func shouldRetry(request *http.Request, response *http.Response, withDelay time.
}

// check for unexpected EOF
bodyBytes, err := ioutil.ReadAll(response.Body)
bodyBytes, err := io.ReadAll(response.Body)
response.Body.Close()
if err != nil {
log.WithError(err).Error("error reading ES response, retrying")
return true
}

response.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))
response.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
return false
}

Expand All @@ -62,7 +62,7 @@ func MakeJSONRequest(method string, url string, body []byte, dest any) (*http.Re
defer resp.Body.Close()

// if we have a body, try to decode it
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
l.WithError(err).Error("error reading response")
return resp, err
Expand Down

0 comments on commit eb0328d

Please sign in to comment.