How to use the http.get function in http

To help you get started, we’ve selected a few http 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 jwadhams / json-logic-js / tests / tests.js View on Github external
var download = function(url, dest, cb) {
  var file = fs.createWriteStream(dest);
  http.get(url, function(response) {
    response.pipe(file);
    file.on("finish", function() {
      file.close(cb);  // close() is async, call cb after close completes.
    });
  }).on("error", function(err) { // Handle errors
    fs.unlink(dest); // Delete the file async. (But we don't check the result)
    if (cb) cb(err.message);
  });
};
github bastinat0r / Spaceapi_Visualisation / app / app.js View on Github external
function getHttpAndHttps(url, cb) {
	if(/^https/.test(url)) {
		https.get(url, cb).on('error', function(e) {
			util.puts(JSON.stringify(e));
			util.puts(url);
			cb(null);
		});
	} else {
		http.get(url, cb).on('error', function(e) {
			util.puts(JSON.stringify(e));
			util.puts(url);
			cb(null);
		});
	}
}
github STRML / wayback-machine-machine / lib / proxy.js View on Github external
function queryURL(url, cb) {
  if (cache[url]) return cb(null, null, cache[url]);
  http.get(url, function(response) {
    parseBody(response, function(body){
      cache[url] = body;
      cb(null, response, body);
    });
  })
  .on('error', function(err) {
    cb(err);
  });
}
github rem-bot-industries / rem-v2 / src / modules / audio / WolkeStream.js View on Github external
request(url, length) {
        const options = typeof url === 'string' ? URL.parse(url) : url;
        if (!options.headers) options.headers = {};
        if (length > 0) {
            options.headers.Range = `bytes=${length}-`;
        }
        if (options.protocol === 'https:') {
            let req = https.get(options, (res) => {
                this.processRes(req, res);
            });
        } else {
            let req = http.get(options, (res) => {
                this.processRes(req, res);
            });
        }
    }
github adambard / fungibility / app.js View on Github external
function fetch(uri, callback){
    uri = url.parse(uri);
    if(uri.protocol === "https:"){
        return https.get(uri, callback);
    }else{
        return http.get(uri, callback);
    }
}

http

security holding package

Unknown
Latest version published 5 years ago

Package Health Score

47 / 100
Full package analysis