MCPcopy Create free account
hub / github.com/OpenReservation/OpenReservation / parseHeaders

Function parseHeaders

OpenReservation/wwwroot/Scripts/angular.js:10431–10454  ·  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

10429 * @returns {Object} Parsed headers as key value object
10430 */
10431 function parseHeaders(headers) {
10432 var parsed = createMap(), i;
10433
10434 function fillInParsed(key, val) {
10435 if (key) {
10436 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
10437 }
10438 }
10439
10440 if (isString(headers)) {
10441 forEach(headers.split('\n'),
10442 function (line) {
10443 i = line.indexOf(':');
10444 fillInParsed(lowercase(trim(line.substr(0, i))), trim(line.substr(i + 1)));
10445 });
10446 } else if (isObject(headers)) {
10447 forEach(headers,
10448 function (headerVal, headerKey) {
10449 fillInParsed(lowercase(headerKey), trim(headerVal));
10450 });
10451 }
10452
10453 return parsed;
10454 }
10455
10456 /**
10457 * Returns a function that provides access to parsed headers.

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