Created
July 15, 2017 19:46
-
-
Save Munter/f6156a3f96f045c9b07ad6f1aec0dee1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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