Skip to content

Instantly share code, notes, and snippets.

@kostasx
Last active August 29, 2015 14:07
Show Gist options
  • Save kostasx/f5b020c3fbd31e0bb428 to your computer and use it in GitHub Desktop.
Save kostasx/f5b020c3fbd31e0bb428 to your computer and use it in GitHub Desktop.
Node.js - Get File using HTTPS
var https = require('https');
var fs = require('fs');
var options = {
hostname : 'wordpress.org',
port : 443,
path : '/latest.zip',
method : 'GET'
};
var file = fs.createWriteStream("wp_latest.zip");
var req = https.request(options, function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
file.write(d);
});
});
req.end();
req.on('error', function(e) {
console.error(e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment