Registry / serialization / http-string-parser

http-string-parser

JSON →
library0.0.6jsnpmunverified

http-string-parser is a lightweight, proof-of-concept library designed to parse raw HTTP request and response messages from strings within Node.js environments. The package is currently at version 0.0.6, with its last known update in 2014, indicating it is no longer actively maintained. Its core functionality offers methods like `parseRequest`, `parseResponse`, `parseRequestLine`, `parseStatusLine`, and `parseHeaders` to break down HTTP messages into structured JavaScript objects. A key differentiator is its explicit admission of being a 'naive' parser, not leveraging Node.js core's C bindings for HTTP parsing or more robust alternatives like `http-pegjs`, which were even suggested as future replacements in its own README. It serves as a basic utility for scenarios where a simple, non-production-grade parsing of well-formed HTTP strings is sufficient, but lacks the robustness and ongoing support expected for modern applications.

npm install http-string-parser
INSTALL
IMPORT
SIG · HTTP-STRING-PARSER
H
http-string-parser
serializationjavascriptv0.0.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parser
const parser = require('http-string-parser');
import parser from 'http-string-parser';
The package is CommonJS-only and has not been updated since 2014. ESM `import` statements are not supported directly without a transpilation layer or explicit CommonJS wrapping.
parseRequest
const { parseRequest } = require('http-string-parser');
import { parseRequest } from 'http-string-parser';
While CommonJS allows direct destructuring from `require`, the primary API pattern presented in the documentation is accessing methods via the `parser` object (`parser.parseRequest`). Direct destructuring works as the module exports an object containing these functions.
parseResponse
const parser = require('http-string-parser'); const response = parser.parseResponse(responseString);
import { parseResponse } from 'http-string-parser';
Similar to `parseRequest`, `parseResponse` is a method on the default exported object. Direct `import` from ES modules will fail.

Demonstrates parsing a raw HTTP request and response string into structured JavaScript objects using the `parseRequest` and `parseResponse` methods.

const parser = require('http-string-parser'); const httpRequestString = `GET /api/data?id=123 HTTP/1.1\r\nHost: example.com\r\nUser-Agent: NodeParser/1.0\r\nContent-Type: application/json\r\nContent-Length: 20\r\n\r\n{"message": "hello"}`; const httpResponseString = `HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: 22\r\n\r\n{"status": "success"}`; try { console.log('Parsing HTTP Request:'); const request = parser.parseRequest(httpRequestString); console.log(JSON.stringify(request, null, 2)); console.log('\nParsing HTTP Response:'); const response = parser.parseResponse(httpResponseString); console.log(JSON.stringify(response, null, 2)); } catch (error) { console.error('An error occurred during parsing:', error.message); }
Debug
Known issues
breakingThis package is effectively abandoned, with its last commit in 2014 and version 0.0.6. It is not compatible with modern Node.js versions out-of-the-box (e.g., ESM modules) and lacks ongoing maintenance for security vulnerabilities or bug fixes.
fix
Consider using actively maintained alternatives like `node:http` built-in parsers (for server-side) or more robust third-party libraries for client-side or generic HTTP message parsing.
affects: >=0.0.1
gotchaThe README explicitly states this is a 'proof of concept, naive HTTP parsing, wheel re-invention.' It does not handle complex HTTP features, malformed requests, or edge cases robustly. Do not use for production systems requiring resilience or full RFC compliance.
fix
Evaluate your parsing requirements carefully. For production-grade HTTP parsing, refer to the `http-parser` used by Node.js core, or well-established HTTP client/server frameworks that encapsulate robust parsing logic.
affects: >=0.0.1
deprecatedThe package's own README suggests it 'may be replaced with better parser from [Node.JS core's C bindings of NGINX HTTP parser] or [PEG.js HTTP parser]'. This indicates it was always intended as a temporary or educational solution.
fix
Favor `http-parser` (used internally by Node.js) or `http-pegjs` if you need string-based parsing with better compliance and performance.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: parser.parseRequest is not a function
Attempting to call `parseRequest` without correctly requiring the module as a CommonJS object, or trying to destructure incorrectly.
fix
Ensure you are using `const parser = require('http-string-parser');` and then calling `parser.parseRequest(...)` or `parser.parseResponse(...)`.
SyntaxError: Cannot use import statement outside a module
Trying to use `import` syntax (`import parser from 'http-string-parser';`) in a Node.js project configured for CommonJS modules.
fix
Convert your file to CommonJS (`const parser = require('http-string-parser');`) or properly configure your project to use ES Modules (e.g., by adding `"type": "module"` to `package.json`), although this package's core functionality is not designed for ESM.
Parsing results are incomplete or incorrect for specific HTTP messages (e.g., chunked encoding, unusual headers).
The parser is 'naive' and does not implement full HTTP RFC compliance, leading to failures or partial parsing for complex or non-standard HTTP messages.
fix
This package is not designed for robust parsing. For complex HTTP scenarios, switch to a more mature and compliant HTTP parsing library or the `node:http` module.
Upgrade
Version history
0.0.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
http-string-parser — npm install http-string-parser · libregistry