function parseHeaders(text) {
  const items = text
    .split('\r\n')
    .map((line) => {
      const kv = line.split(':').map((str) => str.trim());
      kv[0] = kv[0].toLowerCase();
      return kv;
    });

  return itemsToObject(items);
}
Parse HTTP headers from a given string.
@param {String} text the text to parse the headers from
@returns {Object} the parsed headers with lowercase keys