简体   繁体   English

qx.io.remote.Request:在正文和网址中发布参数

[英]qx.io.remote.Request: post parameters in body and url

when creating and sending an http POST request like this... 在创建和发送这样的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();

... paramters are send in the body and in the url. ...参数在正文和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). 我的解决方法是自己连接和uriencode参数,并使用req.setData(data)将它们放在正文中。

.setParameter has an optional third argument. .setParameter具有可选的第三个参数。 If set to true , the parameter for the request will go into the data section instead of the URL; 如果设置为true ,则请求的参数将进入数据部分,而不是URL; see the API doc . 请参阅API文档

Take a look at the documentation at http://demo.qooxdoo.org/current/apiviewer/#qx.io.remote.Request for the setParameter-method. 请参阅http://demo.qooxdoo.org/current/apiviewer/#qx.io.remote.Request中的setParameter方法文档。

setParameter(String vId, var vValue, (Boolean | false) bAsData) has an optional third parameter bAsData setParameter(String vId,var vValue,(Boolean | false)bAsData)具有可选的第三个参数bAsData

If false, add the parameter to the URL. 如果为false,则将参数添加到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(). 如果为true,则通过调用此方法添加的参数将组合为一个字符串,添加为请求数据,就好像整个参数集已预先构建并传递给setData()一样。

So adding an third parameter with the value true to your req.setParameter should do the trick. 因此,向您的req.setParameter添加值为true的第三个参数应该可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM