if(res3.statusCode==302) redirect(res,bHttps,opt,res3.headers.location)
redirect(res,bHttps,opt,res2.headers.location)
redirect(res,bHttps,opt,res3.headers.location)
if(res2.statusCode==302) redirect(res,bHttps,opt,res2.headers.location)
request(options, function(error, response, body) { if (error || [301, 302].indexOf(response.statusCode) == -1) { callback('URL not recognized as supported'); return; } callback(null, response.headers.location); });
function get(options) { http.get(options, (res) => { log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`); log(res.headers); log(''); if(res.statusCode < 400 && res.statusCode >= 300) { get(opt(res.headers.location)); } else { res.pipe(process.stdout); } }); }
// download a binary file function download(url, path) { console.log("Downloading the mkcert executable...") const file = fs.createWriteStream(path) return new Promise(resolve => { function get(url, file) { https.get(url, (response) => { if (response.statusCode === 302) get(response.headers.location, file) else response.pipe(file).on("finish", resolve) }) } get(url, file) }) }
request.post({ url: constants.TON_API_HOST + self.config.ton_api_version + '/ton/bucket/' + params.bucket_name + '?resumable=true', headers: headers, oauth: self._oauthObj }, function(err, resp, body) { if (err) return cb(err); if (resp.statusCode === 201) { var urlPathForChunks = resp.headers.location; var minChunkSize = Number(resp.headers['X-TON-Min-Chunk-Size'.toLowerCase()]); return self._uploadTonChunks(fd, minChunkSize, urlPathForChunks, params, cb); } else { fs.closeSync(fd); console.log('Error Body: ', body); return cb(new Error('TwitterAdsAPI: Twitter TON API returned HTTP status code: ' + resp.statusCode)); } });
const checkHttp = async url => { let response; try { response = await got(url, {rejectUnauthorized: false}); } catch (_) { return false; } if (response.headers && response.headers.location) { const url = new URL(response.headers.location); const hostname = url.hostname.replace(/^\[/, '').replace(/\]$/, ''); // Strip [] from IPv6 return !routerIps.has(hostname); } return true; }
request(options, function(error, response, body) { if (error || response.statusCode != 200) { callback('Unexpected response status code. Response code: ' + response.statusCode); return; } var match = body.match(/\.href = revC\("(.*?)"\)/); if (!match) { callback('Cannot find the target URL'); return; } var redirectUrl = 'https://linkshrink.net/' + new Buffer(match[1], 'base64').toString(); //TODO : Retractor this request({ url: redirectUrl, followRedirect: false }, function(error, response, body) { if (error || response.statusCode != 302) { callback('Unexpected response status code. Response code: ' + response.statusCode); return; } callback(null, response.headers.location); }); });
request(options, function(error, response, body) { if (error || response.statusCode != 302) { callback('Unexpected response status code. Response code: ' + response.statusCode); return; } callback(null, response.headers.location); });
if(res3.statusCode==302) redirect(res,bHttps,opt,res3.headers.location)
if(res3.statusCode==302) redirect(res,bHttps,opt,res3.headers.location)
if(res2.statusCode==302) redirect(res,bHttps,opt,res2.headers.location)
if(res2.statusCode==302) redirect(res,bHttps,opt,res2.headers.location)