
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
http-request-parser
Advanced tools
Parse HTTP request message and create an object model for it
Parse HTTP request message and create an object model for it. Can be used on server and client sides. To build HTTP request message from an object model use http-request-builder.
multipart/form-data
, application/x-www-form-urlencoded
, text/plain
)npm i -S http-request-parser
const parser = require('http-request-parser');
let requestMsg = [
'POST http://app.com/features?p1=v1 HTTP/1.1',
'Host: example.com',
'Connection: keep-alive',
'Cache-Control: no-cache',
'User-Agent: Mozilla/5.0 (Windows NT 6.1 WOW64)',
'Content-Type: multipart/form-data;boundary=------11136253119209',
'Content-Length: 101',
'Cookie: csrftoken=123abc; sessionid=456def',
'Accept: */*',
'Accept-Encoding: gzip,deflate',
'Accept-Language: en-US;q=0.6, en;q=0.4',
'',
'-----------------------------11136253119209',
'Content-Disposition: form-data; name="Name"',
'',
'Smith',
'-----------------------------11136253119209',
'Content-Disposition: form-data; name="Age"',
'',
'25',
'-----------------------------11136253119209--'
].join('\n');
let requestObj = parser.parse(requestMsg);
console.log(requestObj);
/* outputs:
{
method: 'POST',
protocol: 'HTTP',
url: 'example.com/features?p1=v1',
protocolVersion: 'HTTP/1.1',
host: 'example.com',
headers: [
{ name: 'Connection', values: [ { value: 'keep-alive', params: null } ] },
{ name: 'Cache-Control', values: [ { value: 'no-cache', params: null } ] },
{ name: 'User-Agent', values: [
{ value: 'Mozilla/5.0 (Windows NT 6.1 WOW64)', params: null }
]},
{ name: 'Content-Type', values: [ { value: 'multipart/form-data', params: 'boundary=------11136253119209' } ] },
{ name: 'Content-Length', values: [ { value: '101', params: null } ] },
{ name: 'Accept', values: [ { value: '/', params: null } ] },
{ name: 'Accept-Encoding', values: [
{ value: 'gzip', params: null },
{ value: 'deflate', params: null }
]},
{ name: 'Accept-Language', values: [
{ value: 'en-US', params: 'q=0.6' },
{ value: 'en', params: 'q=0.4' }
]}
],
cookie: [
{ name: 'csrftoken', value: '123abc' },
{ name: 'sessionid', value: '456def' }
],
body: {
contentType: 'multipart/form-data',
boundary: '------11136253119209',
formDataParams: [
{ name: "Name", value: "Smith" },
{ name: "Age", value: "25" }
]
}
}
*/
Alexander Mac
Licensed under the MIT license.
FAQs
Parse HTTP request message and create an object model for it
The npm package http-request-parser receives a total of 14 weekly downloads. As such, http-request-parser popularity was classified as not popular.
We found that http-request-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.