【发布时间】:2011-09-16 00:46:26
【问题描述】:
我正在尝试使用协议分析器 (Charles) 捕获 node.js http 流量,但无法让节点使用代理。有没有办法让节点 http 和 https 模块使用代理?
顺便说一下,我正在使用 OSX
【问题讨论】:
标签: http macos node.js proxy https
我正在尝试使用协议分析器 (Charles) 捕获 node.js http 流量,但无法让节点使用代理。有没有办法让节点 http 和 https 模块使用代理?
顺便说一下,我正在使用 OSX
【问题讨论】:
标签: http macos node.js proxy https
感谢 Chris 在我的情况下,我使用的是 Charles 和 Request 模块。有一个句柄proxy option 可以放置您的查尔斯端口。
所以要在Charles菜单的Proxy->Proxy Settings->Http Proxy中找到你的端口
在任何请求中使用此端口号,例如:
request.get(url, {
'proxy': 'http://localhost:<charles-proxy-port>'
}, function (error, response, body) {
//did you see me in Charles??
});
【讨论】:
想通了。我按照How can I use an http proxy with node.js http.Client? 的指示进行操作 我认为我需要使用 https 来访问代理。但是,如果我使用 http 访问代理,并通过例如'路径:'https://www.google.com/accounts/OAuthGetRequestToken',那么它就可以工作了......
【讨论】: