Skip to content

Commit

Permalink
Merge pull request #8 from Mastercard/feature/read-latest-body
Browse files Browse the repository at this point in the history
Read latest request body instead of snapshot copy
  • Loading branch information
danny-gallagher authored Sep 20, 2023
2 parents 5391c60 + 864da90 commit 509997a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package oauth
import (
"crypto/rsa"
"errors"
"io/ioutil"
"io"
"net/http"
)

Expand Down Expand Up @@ -44,11 +44,11 @@ func getRequestBody(req *http.Request) ([]byte, error) {
if req.Body == nil {
return nil, nil
}
getBody, e := req.GetBody()
if e != nil {
return nil, e
bodyBytes, err := io.ReadAll(req.Body)
if err != nil {
return nil, err
}
defer func() { _ = getBody.Close() }()
defer req.Body.Close()

return ioutil.ReadAll(getBody)
return bodyBytes, nil
}

0 comments on commit 509997a

Please sign in to comment.