Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript GET请求不会仅在Node.JS内返回?_Javascript_Node.js_Https - Fatal编程技术网

Javascript GET请求不会仅在Node.JS内返回?

Javascript GET请求不会仅在Node.JS内返回?,javascript,node.js,https,Javascript,Node.js,Https,出于某种原因,此请求GET从未返回,但仅在Node.js中返回。我试过浏览器、curl、httparty、ruby'snet::Http、postman、clojure,它们都很好用。Node.js将不会 这将如您所期望的那样返回 echo "require('https').get('https://github.com/jakecraige.json', function(res) { console.log(res); });" | node 这种情况永远不会重现,它最终会引发经济危机

出于某种原因,此请求GET从未返回,但仅在Node.js中返回。我试过浏览器、curl、httparty、ruby'snet::Http、postman、clojure,它们都很好用。Node.js将不会

这将如您所期望的那样返回

echo "require('https').get('https://github.com/jakecraige.json', function(res) { console.log(res); });" | node
这种情况永远不会重现,它最终会引发经济危机

echo "require('https').get('https://gateway.rpx.realpage.com/rpxgateway/PricingAndAvailability.svc?wsdl', function(res) { console.log(res); });" | node
如果有人能对此提供一些见解,那将非常有帮助

谢谢

$ curl 'https://gateway.rpx.realpage.com/rpxgateway/PricingAndAvailability.svc' -I
HTTP/1.1 400 Bad Request

试着提供一个错误处理程序,看看你得到了什么。

IRC中的Zyri将我引向这里,找到了解决问题的方法


看起来它需要node.js中的SSLv3_方法,无论我选择哪个URL,您的代码都会挂起。我相信这是节点试图确保我们不会过早退出,运行它的事件循环以防万一。您列出的所有其他技术都是同步的,而不是事件驱动的。另外,
res
可能不是您想要打印的内容,因为它是节点的内部响应对象。试试这个:

cat <<EOF | node
require("https").get("https://github.com/jakecraige.json",
  function(res) {
    var body = ''
    res.
      on('data', function(data) { body += data}).
      on('end', function() { console.log(body); process.exit(0); });
  }
);
EOF

cat将@constrar链接与这篇原始文章结合起来,我已经构造了一个请求,得到了一个有效的响应

var https = require('https');
https.globalAgent.options.secureProtocol = 'SSLv3_method';

https.get("https://gateway.rpx.realpage.com/rpxgateway/PricingAndAvailability.svc?wsdl", function(res) {
  console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
  console.log("Got error: " + e.message);
});            

看起来我需要将?wsdl附加到url的末尾以获得有效的请求。尽管解决方案不同