MCPcopy Create free account
hub / github.com/nodejs/node / requestHeadersArrayToDictionary

Function requestHeadersArrayToDictionary

lib/internal/inspector/network_undici.js:20–36  ·  view source on GitHub ↗
(headers)

Source from the content-addressed store, hash-verified

18
19// Convert an undici request headers array to a plain object (Map<string, string>)
20function requestHeadersArrayToDictionary(headers) {
21 const dict = {};
22 let charset;
23 let mimeType;
24 for (let idx = 0; idx < headers.length; idx += 2) {
25 const key = `${headers[idx]}`;
26 const value = `${headers[idx + 1]}`;
27 dict[key] = value;
28
29 if (StringPrototypeToLowerCase(key) === 'content-type') {
30 const result = sniffMimeType(value);
31 charset = result.charset;
32 mimeType = result.mimeType;
33 }
34 }
35 return [dict, charset, mimeType];
36};
37
38// Convert an undici response headers array to a plain object (Map<string, string>)
39function responseHeadersArrayToDictionary(headers) {

Callers 1

onClientRequestStartFunction · 0.85

Calls 1

sniffMimeTypeFunction · 0.85

Tested by

no test coverage detected