Skip to content

Instantly share code, notes, and snippets.

@Munter
Created July 15, 2017 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Munter/f6156a3f96f045c9b07ad6f1aec0dee1 to your computer and use it in GitHub Desktop.
Save Munter/f6156a3f96f045c9b07ad6f1aec0dee1 to your computer and use it in GitHub Desktop.
var request = require('request');
console.log('Checking availability of https://jspm.io');
request({
method: 'head',
url: 'https://jspm.io',
strictSSL: true,
gzip: true,
headers: {
// 'User-Agent': 'Hyperlink v' + version + ' (https://www.npmjs.com/package/hyperlink)',
// 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate, sdch, br'
}
}, function (err, res) {
if (err) {
throw err;
}
console.log('HEAD statusCode', res.statusCode);
if (res.statusCode === 502) {
console.log('retrying with GET');
request({
method: 'get',
url: 'https://jspm.io',
strictSSL: true,
gzip: true,
headers: {
// 'User-Agent': 'Hyperlink v' + version + ' (https://www.npmjs.com/package/hyperlink)',
// 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate, sdch, br'
}
}, function (err, res) {
if (err) {
throw err;
}
console.log('GET statusCode', res.statusCode);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment