go-zero
go-zero copied to clipboard
The request body is truncated if it exceeds 8MB
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior, if applicable:
-
The code is
rest\httpx\requests.go reader := io.LimitReader(r.Body, maxBodyLen)
2. The error is
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Environments (please complete the following information):**
- OS: [e.g. Linux]
- go-zero version [e.g. 1.2.1]
- goctl version [e.g. 1.2.1, optional]
**More description**
Add any other context about the problem here.
// ParseJsonBody parses the post request which contains json in body. func ParseJsonBody(r *http.Request, v any) error { if withJsonBody(r) { reader := io.LimitReader(r.Body, maxBodyLen) return mapping.UnmarshalJsonReader(reader, v) }
return mapping.UnmarshalJsonMap(nil, v)
}
There is MaxBytes in config, you can set the max body length.
maxBodyLen is a constant,use in httpx.Parse. setting MaxBytes does not solve the @kevwan
There is
MaxBytesin config, you can set the max body length.