How to enable verbose/debug log for https module in node.js

Viewed 283

How to enable verbose/debug log (in node.js https module) including handshaking details similar to the following curl command.

curl -v https://example.com/abcd

My Sample code

const https = require('https');
const options = {
  hostname: 'encrypted.google.com',
  port: 443,
  path: '/',
  method: 'GET'
};

const req = https.request(options, (res) => {
  console.log('statusCode:', res.statusCode);
  console.log('headers:', res.headers);

  res.on('data', (d) => {
    process.stdout.write(d);
  });
});

req.on('error', (e) => {
  console.error(e);
});
req.end();
0 Answers
Related