MCPcopy
hub / github.com/agent-infra/sandbox / mergeHeaders

Function mergeHeaders

sdk/js/src/core/headers.ts:1–18  ·  view source on GitHub ↗
(
    ...headersArray: (Record<string, THeaderValue> | null | undefined)[]
)

Source from the content-addressed store, hash-verified

1export function mergeHeaders<THeaderValue>(
2 ...headersArray: (Record<string, THeaderValue> | null | undefined)[]
3): Record<string, string | THeaderValue> {
4 const result: Record<string, THeaderValue> = {};
5
6 for (const [key, value] of headersArray
7 .filter((headers) => headers != null)
8 .flatMap((headers) => Object.entries(headers))) {
9 const insensitiveKey = key.toLowerCase();
10 if (value != null) {
11 result[insensitiveKey] = value;
12 } else if (insensitiveKey in result) {
13 delete result[insensitiveKey];
14 }
15 }
16
17 return result;
18}
19
20export function mergeOnlyDefinedHeaders<THeaderValue>(
21 ...headersArray: (Record<string, THeaderValue> | null | undefined)[]

Callers 15

constructorMethod · 0.90
__getInfoMethod · 0.90
__screenshotMethod · 0.90
__executeActionMethod · 0.90
__setConfigMethod · 0.90
__restartMethod · 0.90
__getProxyPacMethod · 0.90
__executeCodeMethod · 0.90
__getInfoMethod · 0.90
__listSessionsMethod · 0.90
__deleteSessionsMethod · 0.90
__deleteSessionMethod · 0.90

Calls 1

entriesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…