lib-stream-http

create a duplex stream representing the http connection

lib-stream-http

create a duplex stream representing the http connection

npm install --save lib-stream-http
var Requestor = require('lib-stream-http')();
var requestor = Requestor.New();
 
var opts = {
  host: 'myhost.example.com',
  path: '/somet/path',
}
 
var duplex = requestor.newDuplex(opts);
 
// generate error on http status >= 400 
// you should still consume the res 
duplex.on('error', function (errres) {
  // cleanup on error 
});
 
// the outStream only gets data if the request succeeds 
inStream.pipe(duplex).pipe(outStream);
  • does not handle 3xx status codes