mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-18 23:52:52 +00:00
docs: added some inline comments
This commit is contained in:
committed by
Rainer Killinger
parent
e70e50a1ea
commit
eabd885cd4
@@ -60,6 +60,7 @@ async function configureApp() {
|
||||
|
||||
// Only accept json as content type
|
||||
if (contentType === '' || contentType.match(/^application\/json$/) === null) {
|
||||
// return an error in the response
|
||||
const err = new SCUnsupportedMediaTypeErrorResponse(isTestEnvironment);
|
||||
res.status(err.statusCode);
|
||||
res.json(err);
|
||||
@@ -67,17 +68,21 @@ async function configureApp() {
|
||||
}
|
||||
|
||||
const bodyBuffer: any[] = [];
|
||||
// we don't know the full size, the only way we can get is by adding up all individual chunk sizes
|
||||
let bodySize = 0;
|
||||
const chunkGatherer = (chunk: Buffer) => {
|
||||
bodySize += chunk.byteLength;
|
||||
// when adding each chunk size to the total size, check how large it now is.
|
||||
if (bodySize > 512 * 1024) {
|
||||
req.off('data', chunkGatherer);
|
||||
req.off('end', endCallback);
|
||||
// return an error in the response
|
||||
const err = new SCRequestBodyTooLargeErrorResponse(isTestEnvironment);
|
||||
res.status(err.statusCode);
|
||||
res.json(err);
|
||||
return;
|
||||
}
|
||||
// push the chunk in the buffer
|
||||
bodyBuffer.push(chunk);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user