Code
https_by_proxy.js
var Http = require('http');
var Tls = require('tls');
var req = Http.request({
host: 'web-proxy.xxx.hp.com',
port: 8080,
method: 'CONNECT',
path: 'www.baidu.com:443',
});
req.on('connect', function (res, socket, head) {
var cts = Tls.connect({
host: 'www.baidu.com',
socket: socket
}, function () {
cts.write('GET / HTTP/1.1\r\nHost: www.baidu.com\r\n\r\n');
});
cts.on('data', function (data) {
console.log(data.toString());
});
});
req.end();
Run cmd
node https_by_proxy.js