lib-stream-http

0.0.3 • Public • Published

lib-stream-http

create a duplex stream representing the http connection

install

npm install --save lib-stream-http

usage

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 (err, res) {
  // cleanup on error
});
 
// the outStream only gets data if the request succeeds
inStream.pipe(duplex).pipe(outStream);

limitations

  • does not handle 3xx status codes

see also

Readme

Keywords

none

Package Sidebar

Install

npm i lib-stream-http

Weekly Downloads

2

Version

0.0.3

License

ISC

Last publish

Collaborators

  • groundwater