qx.io.remote.Request:在body和url中post参数

发布于 2024-08-26 17:54:27 字数 435 浏览 5 评论 0原文

当创建和发送这样的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

失去的东西太少 2024-09-02 17:54:27

.setParameter 有一个可选的第三个参数。如果设置为true,请求的参数将进入数据部分而不是URL;请参阅 API 文档

.setParameter has an optional third argument. If set to true, the parameter for the request will go into the data section instead of the URL; see the API doc.

柠栀 2024-09-02 17:54:27

请查看 http://demo.qooxdoo 中的文档。 org/current/apiviewer/#qx.io.remote.Request 用于 setParameter 方法。

setParameter(String vId, var vValue, (Boolean | false) bAsData) 有一个可选的第三个参数 bAsData

如果为 false,则将参数添加到
网址。如果为真则改为
通过调用此添加的参数
方法将被组合成一个字符串
添加为请求数据,就好像
整组参数已
预构建并传递给 setData()。

因此,在 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

If false, add the parameter to the
URL. If true then instead the
parameters added by calls to this
method will be combined into a string
added as the request data, as if the
entire set of parameters had been
pre-build and passed to setData().

So adding an third parameter with the value true to your req.setParameter should do the trick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文