我希望了解Polymer中POST调用如何工作。 我知道必须使用POST调用发送敏感信息,例如用户密码和访问令牌。 我尝试过以下操作:
<iron-ajax
id="AjaxPost"
url="/api/login"
method="POST"
content-type="application/x-www-form-urlencoded"
handle-as="json"
on-response="_handleAjaxPostResponse"
on-error="_handleAjaxPostError"
></iron-ajax>
this.$.AjaxPost.params = { email: "abc@gmail.com", password: "password" };
this.$.AjaxPost.generateRequest();
但是,这将在URL中设置参数,可以在浏览器控制台中查看,例如:
POST http://localhost:8080/api/login?email=abc%40mgail.com&password=password 400 (Bad Request)
PUT方法允许您设置正文中的数据,我认为这更加安全。现在我有两个问题:
- 我们是否也可以设置POST方法的正文?或者设置参数与设置正文是相同的吗?
- 如果可能的话,应该如何在服务器端提取数据?
PS:我们没有使用SSL HTTPS连接。 话虽如此,哪种方法可以用于更好的安全性?