Created
September 26, 2016 11:22
-
-
Save fengmk2/674c7bdae325e9dde5307926587dba0c to your computer and use it in GitHub Desktop.
custom lookup on https request
This file contains hidden or 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
'use strict'; | |
const https = require('https'); | |
const dns = require('dns'); | |
var req = https.request({ | |
protocol: 'https:', | |
host: 'r.cnpmjs.org', | |
lookup: function foo(host, dnsopts, callback) { | |
setTimeout(function() { | |
console.log('dns lookup https host: %s', host) | |
dns.lookup(host, dnsopts, callback); | |
}, 1000); | |
}, | |
}) | |
req.on('response', function(response) { | |
console.log('response status: %s, headers: %j', response.statusCode, response.headers); | |
response.resume(); | |
}); | |
req.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
custom lookup won't excute.