enforce request limits in UTF8 bytes
This commit is contained in:
+2
-2
@@ -620,7 +620,7 @@ function readRaw(req, limit = 1024 * 1024) {
|
|||||||
req.on('data', (c) => {
|
req.on('data', (c) => {
|
||||||
if (settled) return;
|
if (settled) return;
|
||||||
buf += c;
|
buf += c;
|
||||||
if (buf.length > limit) { fail(new Error('Gövde çok büyük')); req.destroy(); }
|
if (Buffer.byteLength(buf, 'utf8') > limit) { fail(new Error('Gövde çok büyük')); req.destroy(); }
|
||||||
});
|
});
|
||||||
req.on('end', () => { if (!settled) { settled = true; resolve(buf); } });
|
req.on('end', () => { if (!settled) { settled = true; resolve(buf); } });
|
||||||
req.on('error', fail);
|
req.on('error', fail);
|
||||||
@@ -635,7 +635,7 @@ function readBody(req, limit = 100 * 1024) {
|
|||||||
req.on('data', (c) => {
|
req.on('data', (c) => {
|
||||||
if (settled) return;
|
if (settled) return;
|
||||||
data += c;
|
data += c;
|
||||||
if (data.length > limit) { fail(new Error('gövde çok büyük')); req.destroy(); }
|
if (Buffer.byteLength(data, 'utf8') > limit) { fail(new Error('gövde çok büyük')); req.destroy(); }
|
||||||
});
|
});
|
||||||
req.on('end', () => {
|
req.on('end', () => {
|
||||||
if (settled) return;
|
if (settled) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user