Skip to content

The request body is truncated if it exceeds 8MB #4899

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

Open
LGQ17 opened this issue May 26, 2025 · 3 comments
Open

The request body is truncated if it exceeds 8MB #4899

LGQ17 opened this issue May 26, 2025 · 3 comments

Comments

@LGQ17
Copy link

LGQ17 commented May 26, 2025

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. 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.
@LGQ17
Copy link
Author

LGQ17 commented May 26, 2025

// 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)

}

@kevwan
Copy link
Contributor

kevwan commented May 28, 2025

There is MaxBytes in config, you can set the max body length.

@LGQ17
Copy link
Author

LGQ17 commented May 28, 2025

maxBodyLen is a constant,use in httpx.Parse. setting MaxBytes does not solve the @kevwan

There is MaxBytes in config, you can set the max body length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants