【问题标题】:Http request through Cntlm proxy.通过 Cntlm 代理的 Http 请求。
【发布时间】:2013-06-27 10:06:27
【问题描述】:

我正在尝试通过 NodeJs 上的 Cntlm 代理发出 HTTP 请求,但我无法使其工作。这是我的代码:

var http = require('http');

var options = {
  host: 'http://127.0.0.1',
  port: 3128,
  path: "http://www.google.com",
  headers: {
    Host: "www.google.com"
  }
};

http.get(options, function(res) {
  console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
  console.log("Got error: " + e.stack);
});

我总是收到以下错误:

Got error: Error: getaddrinfo ENOTFOUND
at errnoException (dns.js:37:11)
at Object.onanswer [as oncomplete] (dns.js:124:16)

请帮忙。

【问题讨论】:

    标签: javascript node.js http ntlm


    【解决方案1】:

    我发现 options.host 不应该有协议('http://')。删除它会给我一个 302-Found。只需将 www.google.com 更改为非重定向 URL 即可获得 200-Ok。

    【讨论】:

      猜你喜欢
      • 2011-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多