rawheaders2obj

0.0.2 • Public • Published

rawheaders2obj

Parse http rawHeaders to object without lowercase.

Installation

npm install rawheaders2obj

Example

Input

const { getObjFromRawHeaders } = require("./index")
const rawHeadersObj = [
  "Server",
  "Github.com",
  "Server",
  "Gitlab.com",
  "A",
  "c",
  "A",
  "d",
  "date",
  "Tue",
  "date",
  "Fri",
  "cookie",
  "a=b; b=c",
  "set-cookie",
  "a=b",
  "set-cookie",
  "b=c",
  "referer",
  "https://github.com",
  "referer",
  "https://gitlab.com",
  "Connection",
  "close",
  "Content-Length",
  "2"
]
const transformObj = getObjFromRawHeaders(rawHeaders)

console.log(transformObj)

Output

{
    Server: 'Github.com',
    A: 'c, d',
    date: 'Tue, Fri',
    cookie: 'a=b; b=c',
    'set-cookie': [ 'a=b', 'b=c' ],
    referer: 'https://github.com',
    Connection: 'close',
    'Content-Length': '2'
}

License

MIT

Package Sidebar

Install

npm i rawheaders2obj

Weekly Downloads

12

Version

0.0.2

License

MIT

Unpacked Size

8.9 kB

Total Files

4

Last publish

Collaborators

  • lukejyhuang