MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / copyHeaders

Function copyHeaders

console/src/api/apiClient.ts:94–110  ·  view source on GitHub ↗

* Creates a new Headers object and copies headers from fetch arguments * @param fetchArgs Original fetch arguments containing input and options * @returns A new Headers object with copied headers from input and options

(fetchArgs: Parameters<Fetch>)

Source from the content-addressed store, hash-verified

92 * @returns A new Headers object with copied headers from input and options
93 */
94function copyHeaders(fetchArgs: Parameters<Fetch>): Headers {
95 const [input, options = {}] = fetchArgs;
96
97 // Start with base headers from input if it's a Request, otherwise empty Headers
98 const headers = new Headers(
99 input instanceof Request ? input.headers : undefined,
100 );
101
102 // Copy any headers from options, overriding existing values
103 if (options.headers) {
104 Object.entries(options.headers).forEach(([key, value]) => {
105 headers.set(key, value);
106 });
107 }
108
109 return headers;
110}
111
112function buildTokenAuthConfig(token: string): TokenAuthConfig {
113 return { token };

Callers 3

CloudApiClientClass · 0.85

Calls 2

entriesMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected