MCPcopy Create free account
hub / github.com/angular/dev-infra / parseRawHeaders

Function parseRawHeaders

github-actions/browserstack/set-browserstack-env.js:1393–1419  ·  view source on GitHub ↗
(headers)

Source from the content-addressed store, hash-verified

1391 return obj;
1392 }
1393 function parseRawHeaders(headers) {
1394 const len = headers.length;
1395 const ret = new Array(len);
1396 let hasContentLength = false;
1397 let contentDispositionIdx = -1;
1398 let key;
1399 let val;
1400 let kLen = 0;
1401 for (let n = 0; n < headers.length; n += 2) {
1402 key = headers[n];
1403 val = headers[n + 1];
1404 typeof key !== "string" && (key = key.toString());
1405 typeof val !== "string" && (val = val.toString("utf8"));
1406 kLen = key.length;
1407 if (kLen === 14 && key[7] === "-" && (key === "content-length" || key.toLowerCase() === "content-length")) {
1408 hasContentLength = true;
1409 } else if (kLen === 19 && key[7] === "-" && (key === "content-disposition" || key.toLowerCase() === "content-disposition")) {
1410 contentDispositionIdx = n + 1;
1411 }
1412 ret[n] = key;
1413 ret[n + 1] = val;
1414 }
1415 if (hasContentLength && contentDispositionIdx !== -1) {
1416 ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString("latin1");
1417 }
1418 return ret;
1419 }
1420 function isBuffer(buffer) {
1421 return buffer instanceof Uint8Array || Buffer.isBuffer(buffer);
1422 }

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected