Skip to content

Commit

Permalink
Avoid clobbering original body for next read
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Coffman <[email protected]>
  • Loading branch information
StevenACoffman committed Aug 24, 2021
1 parent 451764d commit 4a93e90
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion http2curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ func GetCurlCommand(req *http.Request) (*CurlCommand, error) {

if req.Body != nil {
var buff bytes.Buffer
_, err := buff.ReadFrom(req.Body)
bodyReader, err := req.GetBody()
if err != nil {
return nil, fmt.Errorf("getCurlCommand: GetBody error: %w", err)
}
_, err = buff.ReadFrom(bodyReader)
if err != nil {
return nil, fmt.Errorf("getCurlCommand: buffer read from body erorr: %w", err)
}
Expand Down

0 comments on commit 4a93e90

Please sign in to comment.