@browsery/http-parser

中文文档
0.5.10-rev.1发布于 2026/10/07MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 3612

Browser compatible http-parser-js module

原始使用文档
文档目录5 节
  1. Testing
  2. Status
  3. Node versions
  4. Standalone usage
  5. License

Node Node-v12

HTTP Parser

This library parses HTTP protocol for requests and responses. It was created to replace http_parser.c since calling C++ functions 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 is packaged as a standalone npm module. To use in node, monkeypatch HTTPParser.

// Monkey patch before you require http for the first time.
process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;

var http = require('http');
// ...

Testing

Simply run npm test. The tests are copied from node and mscedex/io.js, with some modifcations.

Status

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-14.

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.

Standalone usage

While this module is intended to be used as a replacement for the internal Node.js parser, it can be used as a standalone parser. The standalone-example.js demonstrates how to use the somewhat awkward API (coming from compatibility with the Node.js internals) to parse HTTP from raw Buffers.

License

MIT. See LICENSE.md

版本与发布记录

@browsery/http-parser 共发布 18 个版本,首次发布于 2023/01/10;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.5.10-rev.1latest2026/10/071 个月前
0.5.10-r32026/04/047 个月前
0.5.10-r22025/10/231 年前
0.5.102025/10/231 年前
0.5.9-r42024/08/232 年前
0.5.9-r32024/08/202 年前

关于 @browsery/http-parser 的常见问题

@browsery/http-parser 是什么?

Browser compatible http-parser-js module

如何安装 @browsery/http-parser?

在项目目录运行 npm install @browsery/http-parser,或使用 pnpm add / yarn add / bun add。

@browsery/http-parser 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@browsery/http-parser 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@browsery/http-parser 可以商用吗?

@browsery/http-parser 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@browsery/http-parser 的下载量有多少?

根据 npm 官方下载统计,@browsery/http-parser 在 2026/10/09 – 2026/11/07 这 30 天内被下载 3,612 次,日均约 120 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@browsery/http-parser 还在维护吗?

最新版本 0.5.10-rev.1 发布于 2026/10/07(1 个月前);至今共发布 18 个版本,其中过去 12 个月发布了 2 个;首次发布于 2023/01/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。