qx.io.remote.Request:在body和url中post参数
当创建和发送这样的 http POST 请求时...
var req = new qx.io.remote.Request("/test","POST");
req.setParameter("pi", "3.1415");
req.setParameter("color", "red");
req.setParameter("password", "mySecretPassword");
req.send();
...参数在正文和 url 中发送。这是一个问题,因为参数变大时可能会损坏,并且出于安全原因,所有参数都不能显示在日志文件中。我做错了什么,还是这是一个错误?我的解决方法是自己对参数进行 concat 和 uriencode 并使用 req.setData(data) 将它们放入正文中。
when creating and sending an http POST request like this...
var req = new qx.io.remote.Request("/test","POST");
req.setParameter("pi", "3.1415");
req.setParameter("color", "red");
req.setParameter("password", "mySecretPassword");
req.send();
... paramters are send in the body and in the url. this is a problem because parameters may break when getting bigger, and for security reasons it is not ok for all parameters to show up in logfiles. am i doing something wrong, or is this a bug? my workaround is to concat and uriencode parameters by myself and put them in the body with req.setData(data).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
.setParameter
有一个可选的第三个参数。如果设置为true
,请求的参数将进入数据部分而不是URL;请参阅 API 文档。.setParameter
has an optional third argument. If set totrue
, the parameter for the request will go into the data section instead of the URL; see the API doc.请查看 http://demo.qooxdoo 中的文档。 org/current/apiviewer/#qx.io.remote.Request 用于 setParameter 方法。
setParameter(String vId, var vValue, (Boolean | false) bAsData) 有一个可选的第三个参数 bAsData
因此,在 req.setParameter 中添加第三个值为 true 的参数应该可以解决问题。
Take a look at the documentation at http://demo.qooxdoo.org/current/apiviewer/#qx.io.remote.Request for the setParameter-method.
setParameter(String vId, var vValue, (Boolean | false) bAsData) has an optional third parameter bAsData
So adding an third parameter with the value true to your req.setParameter should do the trick.