node.js - 将选项与 Node 的作用域 http 客户端一起使用,将rejectUnauthorized 设置为 false

标签 node.js https coffeescript

使用 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 optionshttphttps:

   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/

相关文章:

javascript - 如何在使用 node.js 时将数据发送到指定连接

node.js - 从套接字 io 访问 Express session

javascript - 使用 node.js 从 Spring Boot 2 响应中读取传入的 HTTPS header

javascript - 这个函数是做什么的?

javascript - NodeJS 理解事件队列

javascript - 将导出方法要求到类(原型(prototype)?)中的正确方法

android - https 连接适用于 Wifi (wlan) 但不适用于 3G/GPRS (umts)

https - 如何执行来自Phoenix的HTTPS请求并忽略CA错误

inheritance - 当且仅当父类具有该函数时调用 super

javascript - 无法调用 java/coffeescript 中的实例方法