我正在开发一个节点js Server。客户端是使用QNetworkRequest的QT App。不幸的是,QT客户端使用第三方lib向服务器发送GET请求。所以我们无法修改请求。客户端将http GET请求发送为:
http://user:password@127.0.0.1:17/sample_get_req
节点Js服务器代码
app.get(SAMPLE_GET_REQ, function (req, res) {
console.log("req.credentials "+JSON.stringify(req.credentials));
console.log("req.context "+JSON.stringify(req.context));
console.log("req.destination "+JSON.stringify(req.destination ));
console.log("req.url "+JSON.stringify(req.url ));
console.log("req.headers "+JSON.stringify(req.headers ));
console.log("req.body "+JSON.stringify(req.body ));
res.status(200).end();
})
日志:
req.credentials undefined
req.context undefined
req.destination undefined
req.url "/sample_get_req"
req.headers {"host":"127.0.0.1:1729","user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate","connection":"keep-alive","upgrade-insecure-requests":"1","cache-control":"max-age=0"}
req.body undefined
我已经使用base-auth module进行了检查,但我了解base-auth模块在请求中查找“Authorization”标头。我检查了服务器中的http GET请求,授权标头信息不可用。
如何从节点js服务器中的url检索用户和密码?