使用 Node 的 HTTP 库,我可以轻松设置我想要的选项
options =
port: 443
path: "/"
method: 'GET'
rejectUnauthorized: false
https.get options, (res) ->
...
如何使用 node-scoped-http-client 执行相同的操作?
# Passing options doesn't seem to work (defined as above)
cli = msg.http(stats_url, options)
# Injecting it doesn't pass it on either
cli.options['rejectUnauthorized'] = false
我仍然收到此错误:ERROR 错误:UNABLE_TO_VERIFY_LEAF_SIGNATURE
我还缺少其他东西吗?我对 Node 和 CoffeeScript 还很陌生。
最佳答案
简短回答:
你不能。目前,仅限scoped-http-client passes on certain options到 http
或 https
:
req = (if @options.protocol == 'https:' then https else http).request(
port: port
host: @options.hostname
method: method
path: @fullPath()
headers: headers
agent: @options.agent or false
)
长答案:
将其添加到您自己的 fork 中,发送拉取请求。便宜的方法是将其直接添加到上面的请求调用中。处理它的更好方法是实际使用创建客户端时传入的选项对象。
关于node.js - 将选项与 Node 的作用域 http 客户端一起使用,将rejectUnauthorized 设置为 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20296212/