Example #1
0
CombinedStream.prototype.append = function(stream) {
  var isStreamLike = CombinedStream.isStreamLike(stream);

  if (isStreamLike) {
    if (!(stream instanceof DelayedStream)) {
      var newStream = DelayedStream.create(stream, {
        maxDataSize: Infinity,
        pauseStream: this.pauseStreams,
      });
      stream.on('data', this._checkDataSize.bind(this));
      stream = newStream;
    }

    this._handleErrors(stream);

    if (this.pauseStreams) {
      stream.pause();
    }
  }

  this._streams.push(stream);
  if (this._released && !this._currentStream) {
    this._getNext()
  }
  return this;
};
Example #2
0
 '/tests/timeout$': function (req, res) {
     var delayed = DelayedStream.create(req)
     setTimeout(function() {
       res.writeHead(200, {
           'Expires': 0
         , 'Cache-Control': 'max-age=0, no-cache, no-store'
       })
       req.query.callback && res.write(req.query.callback + '(')
       res.write(JSON.stringify({ method: req.method, query: req.query, headers: req.headers }))
       req.query.callback && res.write(');')
       delayed.pipe(res)
     }, 2000)
 },