feat(http): decouple upload size limit from maxReqSize and harden file upload (#4780)

- Add maxUploadSize config (default 1GB) for custom HttpBody streaming uploads;
  maxReqSize now only controls in-memory buffering threshold
- Reject uploads exceeding maxUploadSize with 413 before writing any data
- Delete incomplete files on HttpFileStorage destruction
- Open HttpFileStorage in "wb" mode instead of "ab" to avoid stale data
- Pass content_size to writeData() for integrity validation
- Use uint64_t for content_len to support large file uploads
- Wrap HttpBody _on_completed callback in try-catch to prevent unhandled exceptions
- Make GET_CONFIG global variables read-only
- Update ZLToolKit submodule

---------

Co-authored-by: xiongziliang <771730766@qq.com>
This commit is contained in:
YuLi
2026-07-22 22:55:35 -07:00
committed by GitHub
parent daaa74a72e
commit 4a24057e73
8 changed files with 100 additions and 32 deletions

View File

@@ -401,6 +401,10 @@ keepAliveSecond=30
# http请求体最大字节数如果post的body太大则不适合缓存body在内存
# Maximum number of bytes for the HTTP request body. If the POST body is too large, it is not suitable to cache the body in memory.
maxReqSize=40960
# 自定义HttpBody流式接收请求体的最大字节数maxReqSize仍仅控制内存缓存阈值
# Maximum request body size streamed into a custom HttpBody; maxReqSize remains an in-memory buffering threshold
maxUploadSize=1073741824
# 404网页内容用户可以自定义404网页
# Custom 404 page content. Users can customize the 404 response page here.
#notFound=<html><head><title>404 Not Found</title></head><body bgcolor="white"><center><h1>您访问的资源不存在!</h1></center><hr><center>ZLMediaKit-4.0</center></body></html>