MCPcopy
hub / github.com/JakeChampion/fetch / parseHeaders

Function parseHeaders

fetch.js:433–459  ·  view source on GitHub ↗
(rawHeaders)

Source from the content-addressed store, hash-verified

431}
432
433function parseHeaders(rawHeaders) {
434 var headers = new Headers()
435 // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
436 // https://tools.ietf.org/html/rfc7230#section-3.2
437 var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ')
438 // Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
439 // https://github.com/github/fetch/issues/748
440 // https://github.com/zloirock/core-js/issues/751
441 preProcessedHeaders
442 .split('\r')
443 .map(function(header) {
444 return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
445 })
446 .forEach(function(line) {
447 var parts = line.split(':')
448 var key = parts.shift().trim()
449 if (key) {
450 var value = parts.join(':').trim()
451 try {
452 headers.append(key, value)
453 } catch (error) {
454 console.warn('Response ' + error.message)
455 }
456 }
457 })
458 return headers
459}
460
461Body.call(Request.prototype)
462

Callers 1

fetchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…