web-stream

transform stream for http with optional retry

npm install web-stream
8 downloads in the last month

web-stream

Transform objects to http responses with configurable retry strategy.

Construct the stream:

 new WebStream([{[maxBackoff,[shouldRetry]]}])

Where maxBackoff is the maximum amount of time to wait between retries (i.e. 3000 is 3 seconds), shouldRetry is a function with three arguments (err, res, body) and returns a boolean truth-y to retry false-y to continue.

Wire it to another stream for input that sends in:

 {
   url : 'http://some/url',
   method : 'GET'
 }

For HTTP methods that make sense you may also send in: 'body' and 'header' attributes in this object.

Which will be passed to request as it's options paramter.

web-stream is compatible with 0.8 node via the readable-stream module.

run the example:

 $ npm install
 $ cd example ; node .
npm loves you