Skip to content

Commit

Permalink
Fix unhandled error when preparing HTTP req (#235)
Browse files Browse the repository at this point in the history
* fix unhandled error when preparing HTTP req

* ioutil.ReadAll is deprecated: As of Go 1.16, this function simply calls io.ReadAll
  • Loading branch information
nvthongswansea authored May 17, 2024
1 parent 73cb486 commit e2dcc16
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"runtime"
Expand Down Expand Up @@ -197,6 +197,9 @@ func (r *gsRequest) retryHTTPRequest(ctx context.Context, cfg *Config) (string,
var responseBodyBytes []byte
err := retryNTimes(func() (bool, error) {
httpReq, err := r.prepareHTTPRequest(ctx, cfg)
if err != nil {
return false, err
}
logger.Debugf("Request body: %v", httpReq.Body)
logger.Debugf("Request headers: %v", maskHeaderCred(httpReq.Header))
resp, err := cfg.httpClient.Do(httpReq)
Expand All @@ -221,7 +224,7 @@ func (r *gsRequest) retryHTTPRequest(ctx context.Context, cfg *Config) (string,

statusCode := resp.StatusCode
requestUUID = resp.Header.Get(requestUUIDHeader)
responseBodyBytes, err = ioutil.ReadAll(resp.Body)
responseBodyBytes, err = io.ReadAll(resp.Body)
if err != nil {
logger.Errorf("Error while reading the response's body: %v", err)
return false, err
Expand Down

0 comments on commit e2dcc16

Please sign in to comment.