MCPcopy Create free account
hub / github.com/nock/nock / headersArrayToObject

Function headersArrayToObject

lib/common.js:192–204  ·  view source on GitHub ↗

* Converts an array of raw headers to an object, using the same rules as Nodes `http.IncomingMessage.headers`. * * Header names/keys are lower-cased.

(rawHeaders)

Source from the content-addressed store, hash-verified

190 * Header names/keys are lower-cased.
191 */
192function headersArrayToObject(rawHeaders) {
193 if (!Array.isArray(rawHeaders)) {
194 throw Error('Expected a header array')
195 }
196
197 const accumulator = {}
198
199 forEachHeader(rawHeaders, (value, fieldName) => {
200 addHeaderLine(accumulator, fieldName, value)
201 })
202
203 return accumulator
204}
205
206const noDuplicatesHeaders = new Set([
207 'age',

Callers

nothing calls this directly

Calls 2

forEachHeaderFunction · 0.85
addHeaderLineFunction · 0.85

Tested by

no test coverage detected