You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I have not yet tried to reproduce this. But I have some ideas.
In short once someone reads c.Request.Body it is drained and empty, GetRawData in this case is racing for the data with other parts of the system your other middleware/handler or gin internals to read and close c.Request.Body
ShouldBindBodyWith is set up to be called more than once and saves a copy of the c.Request.Body. I'm not yet sure how it's fixing your issue, but as you report it is.
Guess in general rule for something that reads c.Request.Body means you have taken ownership of that data and need to be responsible for moving it to your next needed middleware or handlerFunc.
I'm not sure to many reasonable ways around this. when I get some time unless someone else does... I'll try to dig in at least enough to know for sure why.
Description
Using FetRawData from an copied context delete the original context body
data, _ := cCp.GetRawData() This line sometimes delete "c" body.
This happen just like in 10% of calls.
Changing GetRawData for ShouldBindBodyWith fix the problem.
Screenshots
The text was updated successfully, but these errors were encountered: