Skip to content

Commit

Permalink
fix: buildCurlRequest() replace req.Body with req.GetBody()
Browse files Browse the repository at this point in the history
  • Loading branch information
tttturtle-russ committed Sep 4, 2024
1 parent 6d941ac commit 24ae356
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion util_curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ func buildCurlRequest(req *http.Request, httpCookiejar http.CookieJar) (curl str

// 3. Generate curl body
if req.Body != nil {
buf, _ := io.ReadAll(req.Body)
// httpclient.Do method will read the entire body and make it empty
// thus using req.GetBody() instead of req.Body since req.Body
// is empty after Do method.
// body here is a copy of original body
body, _ := req.GetBody()
buf, _ := io.ReadAll(body)
req.Body = io.NopCloser(bytes.NewBuffer(buf)) // important!!
curl += `-d ` + shellescape.Quote(string(buf))
}
Expand Down

0 comments on commit 24ae356

Please sign in to comment.