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

Function matchHeaders

deps/undici/src/lib/mock/mock-utils.js:72–94  ·  view source on GitHub ↗
(mockDispatch, headers)

Source from the content-addressed store, hash-verified

70}
71
72function matchHeaders (mockDispatch, headers) {
73 if (typeof mockDispatch.headers === 'function') {
74 if (Array.isArray(headers)) { // fetch HeadersList
75 headers = buildHeadersFromArray(headers)
76 }
77 return mockDispatch.headers(headers ? lowerCaseEntries(headers) : {})
78 }
79 if (typeof mockDispatch.headers === 'undefined') {
80 return true
81 }
82 if (typeof headers !== 'object' || typeof mockDispatch.headers !== 'object') {
83 return false
84 }
85
86 for (const [matchHeaderName, matchHeaderValue] of Object.entries(mockDispatch.headers)) {
87 const headerValue = getHeaderByName(headers, matchHeaderName)
88
89 if (!matchValue(matchHeaderValue, headerValue)) {
90 return false
91 }
92 }
93 return true
94}
95
96function normalizeSearchParams (query) {
97 if (typeof query !== 'string') {

Callers 2

matchKeyFunction · 0.85
getMockDispatchFunction · 0.85

Calls 6

buildHeadersFromArrayFunction · 0.85
lowerCaseEntriesFunction · 0.85
getHeaderByNameFunction · 0.85
matchValueFunction · 0.85
headersMethod · 0.45
entriesMethod · 0.45

Tested by

no test coverage detected