-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] EOF when using ShouldBindJSON #4035
Comments
Trying to reproduce it, for this part:
if err == nil, printing err.Error() will produce an exception For the second part: |
I have the same problem. I had to downgrade to 1.9.1. |
Yes, that is.I think there is no bug actually |
@victor-gapeev There may be some logical problems with the code you write, and request.go explains Body io.ReadCloser and has a rudimentary understanding of its use @rcarrion2 @victor-gapeev If you need to use the data in the Body repeatedly, you can use methods that support caching the Body Methods:
Lines 777 to 817 in 3cb3067
|
IF gin automatically implements binding routing, parameter verification, and generating swaggers, which can reduce a lot of workload when developing the web type UserSearchReq struct { type UserAddReq struct { func GetUserList(c *gin.Context, req *UserSearchReq) (res *UserSearchRes, err error) { func UserAddReq(c *gin.Context, req *UserAddReq) (res *UserAddRes, err error) { |
Description
When I use ctx.ShouldBindJSON(&body), it quietly close request without any response. Other requests with same method works normally.
How to reproduce
Model:
Handler:
Expectations
Correct binding.
Actual result
When I`m making a request, I get the next log:
BUT, if I add lines to print the response as a string before binding, like this:
I got:
I'm sure I don't bind body twice anywhere. I use only cors and log middlewares. This behavior doesn't make any sense and strongly needs explanation.
My code which send requests:
Environment
The text was updated successfully, but these errors were encountered: