Skip to content

Instantly share code, notes, and snippets.

@ryanhugh
Created August 30, 2017 14:46
Show Gist options
  • Save ryanhugh/76b2de2a900cd763399990f63683a90c to your computer and use it in GitHub Desktop.
Save ryanhugh/76b2de2a900cd763399990f63683a90c to your computer and use it in GitHub Desktop.
var request = require('request')
var dns = require('dns');
dns.lookup('www.google.com', (err, address, family) => {
console.log('IP for www.google.com is:', address);
let cookieJarWithIp = request.jar()
let cookieJarWithDomain = request.jar()
request.get({
url: 'https://' + address,
followRedirect: false,
resolveWithFullResponse: true,
headers: {
'Host': 'www.google.com',
'host': 'www.google.com'
},
jar: cookieJarWithIp,
}, function (err, resp) {
console.log('Cookeis with ip:', cookieJarWithIp.getCookies('https://www.google.com'))
console.log('Cookeis with ip:', cookieJarWithIp.getCookies('https://google.com'))
debugger
})
request.get({
url: 'https://www.google.com',
followRedirect: false,
resolveWithFullResponse: true,
headers: {
'Host': 'www.google.com',
'host': 'www.google.com'
},
jar: cookieJarWithDomain,
}, function (err, resp) {
console.log('Cookeis with domain:', cookieJarWithDomain.getCookies('https://www.google.com'))
console.log('Cookeis with domain:', cookieJarWithDomain.getCookies('https://google.com'))
debugger
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment