Nodejs https reqest by proxy(node通过代理进行https请求)

来源:互联网 发布:php正则$1 编辑:程序博客网 时间:2024/05/21 08:57

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

0 0
原创粉丝点击