超过512kib错误处理

This commit is contained in:
lu7213 committed 2026-10-26 09:05:35 -04:00
1 parent 6358dff6e2
commit 829f357bae
3 files changed
+18 -10

No files matched your search

@@ -46,7 +46,9 @@ public class RentalApiController {
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int size;
while ((size = request.getInputStream().read(buffer)) != -1) {
// 可重复读取包装器每次getInputStream()都会从头创建新流,必须持有同一个流读取至EOF。
javax.servlet.ServletInputStream input = request.getInputStream();
while ((size = input.read(buffer)) != -1) {
require(output.size() + size <= RentalJson.MAX_HTTP_BODY_BYTES, "请求体超过512KiB");
output.write(buffer, 0, size);
}