Skip to content

Commit

Permalink
Resolved PR comments'
Browse files Browse the repository at this point in the history
  • Loading branch information
rosspatil committed Jul 12, 2022
1 parent 25ee5d6 commit 2ce6f8f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/roundtripper/roundtripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,22 @@ func (a *AWSSigningTransport) RoundTrip(req *http.Request) (*http.Response, erro
return a.t.RoundTrip(req)
}

func hashPayload(r io.ReadCloser) (payloadHash string, newReader io.ReadCloser, err error) {
var payload []byte
func hashPayload(r io.ReadCloser) (string, io.ReadCloser, error) {
var (
payload []byte
newReader io.ReadCloser
)
if r == nil {
payload = []byte("")
} else {
defer r.Close()
payload, err = ioutil.ReadAll(r)
payload, err := ioutil.ReadAll(r)
if err != nil {
return
return "", newReader, err
}
newReader = ioutil.NopCloser(bytes.NewReader(payload))
}
hash := sha256.Sum256(payload)
payloadHash = hex.EncodeToString(hash[:])
return
payloadHash := hex.EncodeToString(hash[:])
return payloadHash, newReader, nil
}

0 comments on commit 2ce6f8f

Please sign in to comment.