MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / parseHeaders

Function parseHeaders

web/static/bower_components/angular/angular.js:9433–9454  ·  view source on GitHub ↗

* Parse headers into key value object * * @param {string} headers Raw headers as a string * @returns {Object} Parsed headers as key value object

(headers)

Source from the content-addressed store, hash-verified

9431 * @returns {Object} Parsed headers as key value object
9432 */
9433function parseHeaders(headers) {
9434 var parsed = createMap(), i;
9435
9436 function fillInParsed(key, val) {
9437 if (key) {
9438 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
9439 }
9440 }
9441
9442 if (isString(headers)) {
9443 forEach(headers.split('\n'), function(line) {
9444 i = line.indexOf(':');
9445 fillInParsed(lowercase(trim(line.substr(0, i))), trim(line.substr(i + 1)));
9446 });
9447 } else if (isObject(headers)) {
9448 forEach(headers, function(headerVal, headerKey) {
9449 fillInParsed(lowercase(headerKey), trim(headerVal));
9450 });
9451 }
9452
9453 return parsed;
9454}
9455
9456
9457/**

Callers 2

headersGetterFunction · 0.85
doneFunction · 0.85

Calls 7

createMapFunction · 0.85
isStringFunction · 0.85
forEachFunction · 0.85
fillInParsedFunction · 0.85
lowercaseFunction · 0.85
trimFunction · 0.85
isObjectFunction · 0.85

Tested by

no test coverage detected