const http = require('http')
const https = require('https')
// Request with HTTP -> redirects to HTTPS
http.get('http://www.apple.com', res => {
// 301 (Moved Permanently)
console.log(res.statusCode)
// Location: https://www.apple.com/
console.log(res.headers.location)
})
// Request with HTTPS -> successful
https.get('https://www.apple.com', res => {
res.pipe(process.stdout)
})
-
Caleb C. Sander authored25831608