fix(filemode): чистый 413 при теле > лимита (ранняя проверка Content-Length)
This commit is contained in:
@@ -108,6 +108,15 @@ async function handleFile(req, res, config) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1б) Content-Length больше лимита — отказ БЕЗ чтения тела. Иначе при
|
||||||
|
// превышении в процессе чтения мы вынуждены оборвать поток (req.destroy()),
|
||||||
|
// и клиент получает обрыв соединения вместо чистого 413. См. assist.js.
|
||||||
|
const declaredLen = Number.parseInt(req.headers['content-length'], 10);
|
||||||
|
if (Number.isFinite(declaredLen) && declaredLen > MAX_BODY) {
|
||||||
|
jsonError(res, 413, 413, 'body too large');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 2) Тело с лимитом + разбор {content, instruction}.
|
// 2) Тело с лимитом + разбор {content, instruction}.
|
||||||
const read = await readBody(req);
|
const read = await readBody(req);
|
||||||
if (!read.ok) {
|
if (!read.ok) {
|
||||||
|
|||||||
Reference in New Issue
Block a user