api
resource_error
ai_generated
true
413 负载过大:请求实体过大,最大大小为 1048576 字节
413 Payload Too Large: Request entity too large, max size is 1048576 bytes
ID: api/rest-api-request-body-too-large-streaming
90%修复率
90%置信度
1证据数
2024-02-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| HTTP/1.1 RFC 7231 | active | — | — | — |
| Nginx 1.24 | active | — | — | — |
| Express.js 4.18 | active | — | — | — |
根因分析
HTTP 请求体超过了服务器配置的最大负载大小限制,通常用于文件上传或大型 JSON 负载。
English
The HTTP request body exceeds the server-configured maximum payload size limit, typically for file uploads or large JSON payloads.
官方文档
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413解决方案
-
通过移除不必要的字段或使用分页来减小负载大小。示例:使用分块上传或分块传输编码发送数据:curl -X POST https://api.example.com/upload -H 'Transfer-Encoding: chunked' -d @largefile.json
-
增加服务器端最大负载大小限制(如果您控制服务器)。示例 (Nginx):client_max_body_size 10m; (Express.js):app.use(express.json({limit: '10mb'}));
无效尝试
常见但无效的做法:
-
50% 失败
Compressing the request body (e.g., gzip) may not reduce size below the limit if the server counts uncompressed bytes.
-
40% 失败
Splitting the request into multiple smaller requests without proper sequencing may cause data inconsistency or missing data.