docs: added some inline comments

This commit is contained in:
Wieland Schöbl
2019-02-27 14:17:24 +01:00
committed by Rainer Killinger
parent e70e50a1ea
commit eabd885cd4

View File

@@ -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);
};