【发布时间】:2015-01-10 09:20:06
【问题描述】:
我正在开发一个 NodeACS 应用程序,我必须在其中发送 xml 作为来自 Java HTTP 客户端的请求,并在进行一些操作后接收响应。到目前为止,Java HTTP 客户端工作正常,但问题出在 Node JS 文件上。 req.on('data'...) 事件在我的情况下没有触发。 以下是我的 JS 文件的代码:
function index(req, res) {
console.log(req.headers); //Its getting printed on console
req.on('data', function (data) {
console.log("Inside 1"); //Not printed on console
....REST OF THE CODE....
});
req.on('end', function () {
res.writeHead(200);
res.end();
});
}
在上面的代码中,在获取请求后调用 index 函数并打印 console.log(req.headers); 的输出,但如上所述,此后脚本不再运行。请帮我看看我错过了什么。
为了测试,我在我的系统上安装了 cURL,并使用以下命令使用 cURL 请求向服务器发送 POST 请求:
curl -X POST -d @output.xml http://localhost:7788/
【问题讨论】:
标签: javascript node.js express windows-7 titanium