I don’t want to actually follow the re-direct as seen here, I simply want to detect a redirect.
Here is my current code. Please note I want to simply detect a redirect and not do anything with it. The code works fine but downloads gibberish on a redirect.
I don’t want to use any external modules. I believe there is a thing called headers that might come in use.
const https = require('https');
const fs = require('fs');
function download(entry, destination, callback) {
const writeStream = fs.createWriteStream(destination);
const request = https.get(entry, (response) => {
response.pipe(writeStream);
}).on('error', (error) => {
console.log('DEBUG:', error);
});
}
A good example of a redirect is here: