Nodejs https reqest by proxy(node通过代理进行https请求)
2016-12-20 17:52
676 查看
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
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
相关文章推荐
- httpClient通过代理(Http Proxy)进行请求
- iOS开发工具-如何使用网络封包分析工具Charles,通过配置proxy对http、https、tcp、udp 等协议的请求响应过程交互信息进行分析、判断、解决我们移动开发中的遇到的各种实际问题。
- httpClient通过代理(Http Proxy)进行请求
- Window下通过charles代理抓取iphone手机Https请求乱码问题
- 通过 Nginx 反向代理部署 Node.js 服务
- Node.js如何使用代理发送request请求?
- 通过nginx代理拦截请求,进行全局访问限制
- 请求时间过长进行提醒的中间件(了不起的nodejs chapter 8)
- 通过新浪云部署Node.js微信小程序商城(不用买域名、不用备案、不用配置https)
- 完美解决node.js中使用https请求报CERT_UNTRUSTED的问题
- Window下通过charles代理抓取iphone/android手机Https请求乱码问题处理
- node.js请求HTTPS报错:UNABLE_TO_VERIFY_LEAF_SIGNATURE\的解决方法
- 从 iOS,Objective-C, IPhone, iPad, Android, Java, Node.js 或其他平台,或通过其他开发语言,使用WS-Trust请求一个ADFS的令牌
- Nginx反向代理Node.js-https
- node.js通过axios实现网络请求
- HttpClient通过代理进行请求
- Https请求握手验证方式,对相应域名进行认证通过
- 通过js判断访问请求来路进行页面跳转的示例
- 通过 Apache 代理访问 Node.JS, 共享80端口
- Unity 使用自己创建的certificate通过www进行https请求