How to use the request.pipe function in request

To help you get started, we’ve selected a few request examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spmjs / spmjs.io / sync-from-npm / _index.js View on Github external
function _download(url, file, callback) {
  log.info('download', url);
  // TODO: 验证 md5 值,优先级不高
  require('request')(url)
    .pipe(require('fs').createWriteStream(file))
    .on('error', function(err) {
      throw Error(err);
    })
    .on('finish', function() {
      callback();
    });
}
github gucong3000 / Sublime_Text_CN / Han.js View on Github external
fs.stat(filePath, (err, stats) => {
		if (err || !stats.size) {
			console.log("正在下载插件:\tPackage Control");
			require("request")("https://packagecontrol.io/Package%20Control.sublime-package").pipe(fs.createOutputStream(filePath));
			process.on("exit", () => {
				console.log("Package Control已安装,请重启Sublime Text。然后重启本程序");
			});
		}
	});
}
github os-js / OS.js / src / server / node / http.js View on Github external
function respondFile(path, request, response, realPath) {
    var server = {request: request, response: response, config: instance.config, handler: instance.handler};

    if ( !realPath && path.match(/^(ftp|https?)\:\/\//) ) {
      if ( instance.config.vfs.proxy ) {
        try {
          require('request')(path).pipe(response);
        } catch ( e ) {
          instance.logger.log(instance.logger.WARNING, 'respondFile exception', e, e.stack);

          respondError(e, response);
        }
      } else {
        respondError('VFS Proxy is disabled', response);
      }
      return;
    }

    try {
      var fullPath = realPath ? path : instance.vfs.getRealPath(server, path).root;
      _fs.exists(fullPath, function(exists) {
        if ( exists ) {
          var mime = instance.vfs.getMime(fullPath, instance.config);
github rf / moar / example.js View on Github external
var moar = require('./index')();

moar.write('hello');

var req = require('request')('http://nodejs.org').pipe(moar);
req.on('end', moar.end);
moar.on('done', process.exit);
github rf / moar / example2.js View on Github external
var moar = require('./index')();

require('request')('http://nodejs.org').pipe(moar).on('end', moar.end);
github jsreport / jsreport / extension / examples / lib / examples / complexScript.js View on Github external
//some of the node modules like feedparser are available to use
var FeedParser = require("feedparser");

//request.template.content
//request.template.helpers
//request.data
//are available to be modified and change the rendering inputs
request.data = { items: [] };

require('request')('http://www.bbc.co.uk/nature/collections.rss')
   .pipe(new FeedParser())
   .on('readable', function () {
       var stream = this, item;
       while (item = stream.read()) {
           request.data.items.push(item);
       }
   })
   //done is a function script must call at the end to signal async script is done
   .on("end", done);