MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / parseHeaders

Function parseHeaders

out/cli.cjs:47917–47940  ·  view source on GitHub ↗
(headers, obj = {})

Source from the content-addressed store, hash-verified

47915 return headerNameLowerCasedRecord[value] || value.toLowerCase();
47916 }
47917 function parseHeaders(headers, obj = {}) {
47918 if (!Array.isArray(headers)) return headers;
47919 for (let i3 = 0; i3 < headers.length; i3 += 2) {
47920 const key = headers[i3].toString().toLowerCase();
47921 let val = obj[key];
47922 if (!val) {
47923 if (Array.isArray(headers[i3 + 1])) {
47924 obj[key] = headers[i3 + 1].map((x5) => x5.toString("utf8"));
47925 } else {
47926 obj[key] = headers[i3 + 1].toString("utf8");
47927 }
47928 } else {
47929 if (!Array.isArray(val)) {
47930 val = [val];
47931 obj[key] = val;
47932 }
47933 val.push(headers[i3 + 1].toString("utf8"));
47934 }
47935 }
47936 if ("content-length" in obj && "content-disposition" in obj) {
47937 obj["content-disposition"] = Buffer.from(obj["content-disposition"]).toString("latin1");
47938 }
47939 return obj;
47940 }
47941 function parseRawHeaders(headers) {
47942 const ret = [];
47943 let hasContentLength = false;

Callers 1

onHeadersMethod · 0.85

Calls 4

toLowerCaseMethod · 0.80
toStringMethod · 0.45
pushMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…