MCPcopy Index your code
hub / github.com/scality/cloudserver / checkHttpHeadersSize

Function checkHttpHeadersSize

lib/api/apiUtils/object/checkHttpHeadersSize.js:9–23  ·  view source on GitHub ↗

* Checks the size of the HTTP headers * @param {object} requestHeaders - HTTP request headers * @return {object} object with error or null

(requestHeaders)

Source from the content-addressed store, hash-verified

7 * @return {object} object with error or null
8 */
9function checkHttpHeadersSize(requestHeaders) {
10 let httpHeadersSize = 0;
11
12 Object.keys(requestHeaders).forEach(header => {
13 httpHeadersSize += Buffer.byteLength(header, 'utf8') +
14 Buffer.byteLength(requestHeaders[header], 'utf8');
15 });
16
17 if (httpHeadersSize > maxHttpHeadersSize) {
18 return {
19 httpHeadersSizeError: errors.HttpHeadersTooLarge,
20 };
21 }
22 return {};
23}
24
25module.exports = checkHttpHeadersSize;

Callers 1

callApiHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected