package
Transform stream that supports HTTP headers and metadata
npm install http-transformGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
85.4 kB
Includes dependencies.
An extension of the Node.js Transform stream that additionally supports the HTTP header interface.
RequestPair: creates a pair of related streams, one writable, one readable; anything written to the clientWritableSide is readable on the serverReadableSide.ResponsePair: creates a pair of related streams, one writable, one readable; anything written to the serverWritableSide is readable on the clientReadableSide.ResponsePassThrough: creates a Duplex stream that also stores HTTP headers; anything written to it becomes readable. Headers are passed through as exactly as possible. It should typically possible to pipe a response through a ResponsePassThrough instance with no change in behavior. This is typically used to programmatically create a response that's readable the same way a Node.js req object is, and can be piped to a res server response object.RequestPassThrough — Request variation of ResponsePassThroughRequestThroughOrigin — subclass of RequestPair that applies header normalizations, as if the request is actually going through the network.ResponseThroughOrigin — subclass of ResponsePair that applies header normalizations, as if the response is actually going through the network.Mock a readable response object:
function makeResponse(){
const res = new ResponsePassThrough;
res.setHeader('Content-Type', 'text/plain')
res.write('Line\r\n');
return res.readableClientSide;
}Add a Content-Type to a ReadableStream:
const http = require('http');
const { createReadStream } = require('fs');
const { inherits } = require('util');
const { ResponseTransform } = require('.');
const { markdown } = require( "markdown" );
class MarkdownTransform extends ResponseTransform {
constructor() {
super();
const [ input, output ] = this.makeStreams();
output.setHeader('Content-Type', 'application/xhtml+xml');
output.
A subclass of the Node.js Transform that also transforms HTTP headers and status code.
Properties/methods:
Accepts input and passes it to the write target(s).
This can be used to convert a typical ReadableStream into one that produces HTTP headers.
Headers is a simple container for HTTP headers. Its methods and properties are imported into ServerResponseTransform.
Properties/methods, as implemented in Node.js:
Additional methods:
dstdst