nodejs对https站点进行GET调用

时间:2014-07-02 20:52:32

标签: node.js http https proxy

我在ubuntu 12LTS上使用nodejs v0.10.28, 我正在尝试使用此测试代码向Web代理后面的https启用站点发出请求:

 var http = require("http");

    var options = {
        host: "mycompany.proxy.host",
        port: 8088,
        //host: "https://login.launchpad.net",
        //port: 443,
        //path: "/",
        headers: {
           Host: "login.launchpad.net"
        }
     };
     http.get(options, function(res) {
        console.log(res);
        res.pipe(process.stdout);
     }).on('error', function(e) {
        console.log(e);
     });

但不确定用于成功获取HTTP GET的正确选项参数是什么

1 个答案:

答案 0 :(得分:0)

您应该使用节点https而不是http模块来发出https请求。否则,服务器很可能会重置您的连接,并且错误处理程序将捕获ECONNRESET错误。

相关问题