mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
request: fix intermittent race when verbose and reading the body in different routines (#1507)
* fix racerooo * glorious: nits * close after reading --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -171,8 +171,20 @@ func (r *Requester) doRequest(ctx context.Context, endpoint EndpointLimit, newRe
|
||||
log.Debugf(log.RequestSys, "%s request header [%s]: %s", r.name, k, d)
|
||||
}
|
||||
log.Debugf(log.RequestSys, "%s request type: %s", r.name, p.Method)
|
||||
if p.Body != nil {
|
||||
log.Debugf(log.RequestSys, "%s request body: %v", r.name, p.Body)
|
||||
if req.GetBody != nil {
|
||||
bodyCopy, bodyErr := req.GetBody()
|
||||
if bodyErr != nil {
|
||||
return bodyErr
|
||||
}
|
||||
payload, bodyErr := io.ReadAll(bodyCopy)
|
||||
err = bodyCopy.Close()
|
||||
if err != nil {
|
||||
log.Errorf(log.RequestSys, "%s failed to close request body %s", r.name, err)
|
||||
}
|
||||
if bodyErr != nil {
|
||||
return bodyErr
|
||||
}
|
||||
log.Debugf(log.RequestSys, "%s request body: %s", r.name, payload)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user