http-parser-js is a JavaScript implementation of an HTTP protocol parser, designed to replace Node.js's internal C-based `http_parser.c` module. Its primary differentiator is its flexibility and tolerance for malformed or non-standard HTTP data, making it suitable for interacting with legacy services that do not strictly adhere to HTTP parsing rules, unlike Node.js's default stricter parser. The package is currently at version 0.5.10. It does not follow a strict release cadence but updates as needed for compatibility or bug fixes. While originally created to mitigate V8's C++ function call overhead, its current main benefit lies in its error tolerance. It can be used both as a monkey-patch replacement for Node.js's internal parser or as a standalone component for parsing raw HTTP buffers.
npm install http-parser-jsVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to monkey-patch Node.js's internal HTTP parser with `http-parser-js` before initializing the native `http` module, then starts a basic HTTP server.
Run Node.js v12.x with `node --http-parser=legacy file.js` to opt into the older, patchable binding.
Ensure the `process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;` line is at the absolute top of your application's entry point, before any `require('http')` statements.Refer to the `standalone-example.js` in the package's GitHub repository for guidance on how to use the raw `HTTPParser` class for manual parsing.
Only use this package if you specifically need its tolerant parsing behavior or have strong reasons to avoid C++ bindings; otherwise, rely on Node.js's default `http` module behavior.
Execute your Node.js application with the flag: `node --http-parser=legacy your-app.js`
Install the package: `npm install http-parser-js` or `yarn add http-parser-js`
Move the `process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;` line to the very top of your application's main entry file, ensuring it runs before any other code that might implicitly or explicitly load the `http` module.No dependency data recorded yet.