Skip to content

Instantly share code, notes, and snippets.

@fengmk2
Created September 26, 2016 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fengmk2/674c7bdae325e9dde5307926587dba0c to your computer and use it in GitHub Desktop.
Save fengmk2/674c7bdae325e9dde5307926587dba0c to your computer and use it in GitHub Desktop.
custom lookup on https request
'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();
@fengmk2
Copy link
Author

fengmk2 commented Sep 26, 2016

custom lookup won't excute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment