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

Function parseHeaders

github-actions/browserstack/set-browserstack-env.js:1367–1392  ·  view source on GitHub ↗
(headers, obj)

Source from the content-addressed store, hash-verified

1365 return (_a = tree.lookup(value)) != null ? _a : value.toString("latin1").toLowerCase();
1366 }
1367 function parseHeaders(headers, obj) {
1368 if (obj === void 0)
1369 obj = {};
1370 for (let i = 0; i < headers.length; i += 2) {
1371 const key = headerNameToString(headers[i]);
1372 let val = obj[key];
1373 if (val) {
1374 if (typeof val === "string") {
1375 val = [val];
1376 obj[key] = val;
1377 }
1378 val.push(headers[i + 1].toString("utf8"));
1379 } else {
1380 const headersValue = headers[i + 1];
1381 if (typeof headersValue === "string") {
1382 obj[key] = headersValue;
1383 } else {
1384 obj[key] = Array.isArray(headersValue) ? headersValue.map((x) => x.toString("utf8")) : headersValue.toString("utf8");
1385 }
1386 }
1387 }
1388 if ("content-length" in obj && "content-disposition" in obj) {
1389 obj["content-disposition"] = Buffer.from(obj["content-disposition"]).toString("latin1");
1390 }
1391 return obj;
1392 }
1393 function parseRawHeaders(headers) {
1394 const len = headers.length;
1395 const ret = new Array(len);

Callers 1

onHeadersMethod · 0.70

Calls 3

headerNameToStringFunction · 0.70
pushMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected