Socket
Socket
Sign inDemoInstall

http-parser-js

Package Overview
Dependencies
0
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.1 to 0.5.2

11

http-parser.js

@@ -7,2 +7,10 @@ /*jshint node:true */

function HTTPParser(type) {
assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE || type === undefined);
if (type === undefined) {
// Node v12+
} else {
this.initialize(type);
}
}
HTTPParser.prototype.initialize = function (type, async_resource) {
assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE);

@@ -23,3 +31,4 @@ this.type = type;

this.hadError = false;
}
};
HTTPParser.encoding = 'ascii';

@@ -26,0 +35,0 @@ HTTPParser.maxHeaderSize = 80 * 1024; // maxHeaderSize (in bytes) is configurable, but 80kb by default;

5

package.json
{
"name": "http-parser-js",
"version": "0.5.1",
"version": "0.5.2",
"description": "A pure JS HTTP parser for node.",
"main": "http-parser.js",
"scripts": {
"test": "python tests/test.py && node tests/iojs/test-http-parser-durability.js"
"test": "python tests/test.py && node tests/iojs/test-http-parser-durability.js",
"testv12": "python tests/test.py --node-args=\"--http-parser=legacy\" && node --http-parser=legacy tests/iojs/test-http-parser-durability.js"
},

@@ -9,0 +10,0 @@ "repository": {

# HTTP Parser
This library parses HTTP protocol for requests and responses. It was created to replace `http_parser.c` since calling C++ function from JS is really slow in V8.
This library parses HTTP protocol for requests and responses. It was created to replace `http_parser.c` since calling C++ function from JS is really slow in V8. However, it is now primarily useful in having a more flexible/tolerant HTTP parser when dealing with legacy services that do not meet the strict HTTP parsing rules Node's parser follows.
This was further modified by Jimbly to be useable in parsing responses, specifically tested with the "request" module, and addresses issues such as corrupt HTTP headers, which would otherwise cause Node's parser to throw a fatal error (HPE_INVALID_HEADER_TOKEN).
Jan Schär (jscissr) made some bigger changes and added tests. This fixed some bugs and added many missing features.
This is packaged as a standalone npm module. To use in node, monkeypatch HTTPParser.

@@ -25,6 +21,12 @@

This should now be usable in any node application, it now supports (nearly) everything `http_parser.c` does while still being tolerant with corrupted headers.
This should now be usable in any node application, it now supports (nearly) everything `http_parser.c` does while still being tolerant with corrupted headers, and other kinds of malformed data.
### Node Versions
`http-parser-js` should work via monkey-patching on Node v6-v11, and v13.
Node v12.x renamed the internal http parser, and did not expose it for monkey-patching, so to be able to monkey-patch on Node v12, you must run `node --http-parser=legacy file.js` to opt in to the old, monkey-patchable http_parser binding.
## License
MIT. See LICENSE.md
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc