Registry / devops / http-raw

http-raw

JSON →
library2.1.0jsnpmunverified

Creates an HTTP server that exposes the raw request data, including headers and body, as streams. Version 2.1.0 is the latest stable release, with no recent updates (last published circa 2013). It wraps Node's http.createServer but adds req.createRawStream() and req.createRawBodyStream() methods to read/write raw HTTP data without parsing. Useful for proxies or debugging. Different from alternatives like raw-body by giving full control over raw socket data.

npm install http-raw
INSTALL
IMPORT
SIG · HTTP-RAW
H
http-raw
devopsjavascriptv2.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
var createServer = require('http-raw')
import createServer from 'http-raw'
This package is CJS-only and does not ship ESM. ES modules import will fail.
createServer
var createServer = require('http-raw')
var createServer = require('http-raw').createServer
The module exports a function directly, not as a named property.
req.createRawStream
var stream = req.createRawStream()
Method added to the request object inside the server callback. Not exported from the module directly.

Shows how to create an http-raw server, handle GET and other methods, and use a raw body stream to echo back uppercased data.

var createServer = require('http-raw'); var through = require('through'); var server = createServer(function (req, res) { if (req.method === 'GET') { res.end('beep boop\n'); } else { var bs = req.createRawBodyStream(); bs.write('HTTP/1.1 200 OK\r\n\r\n'); bs.pipe(upper()).pipe(bs); } }); server.listen(7000); function upper () { return through(function (buf) { this.emit('data', String(buf).toUpperCase()); }); }
Debug
Known issues
gotchareq.createRawStream() emits the entire raw request including headers; data may contain binary and be large.
fix
Use req.createRawBodyStream() instead if you only need the body after headers.
affects: >=1.0.0
gotchaStreams returned are not parsed; writing invalid HTTP can cause client errors.
fix
Ensure you write correctly formatted HTTP data when using raw streams.
affects: >=1.0.0
deprecatedPackage has not been updated since 2013; may have vulnerabilities or incompatibilities with modern Node versions.
fix
Consider using http.createServer with raw body parsing libraries like raw-body for active maintenance.
affects: >=2.0.0
Errors
Common errors & fixes
createServer is not a function
Trying to import the module using ES module syntax or destructuring require incorrectly.
fix
Use var createServer = require('http-raw'); (no destructuring).
req.createRawStream is not a function
Using the method on a request object from a standard http.createServer (not http-raw).
fix
Make sure to create the server with require('http-raw') instead of require('http').
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

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