HTTP POST 请求的 POST 字符串是否始终为纯文本?

发布于 2024-10-07 20:18:05 字数 177 浏览 3 评论 0原文

正如标题所说:

谈论 HTTP 请求:GET 始终是纯文本形式.. 即 GET www.myresource.com 但是 POST 请求?我知道你可以用 unicode 对其进行编码,但我的问题是: 是对字符串 POST 之后的文本部分进行编码还是同时对字符串 POST 进行编码?总是这样吗?

提前致谢!

as the title says:

speaking about HTTP requests: a GET is always in plain text.. i.e. GET www.myresource.com
but a POST request? I know that you can encode it with unicode but my question is this:
is encoded the part of the text after the string POST or also the string POST? is it always?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

亚希 2024-10-14 20:18:05

您可能需要澄清,但我会回答您所问的问题。

GET 和 POST 请求可以在语法上是等效的...考虑

GET /myscript.php?param=val HTTP/1.1
Host: mysite.com

POST /myscript.php?param=val HTTP/1.1
Host: mysite.com

脚本实际上是以完全相同的方式调用的。区别完全在于语义 - POST 请求应该“做某事”,而 GET 应该始终是安全的。

但是,POST 也可以包含正文。 GET 不能 - 您只能传递 URL 中适合的内容。这允许文件上传,等等,而 GET 不可能做到。具体来说,使用 multipart/form-data 编码,您可以发送未编码的二进制数据。

这就是你问的吗?

You may need to clarify, but I'll answer what I think you're asking.

GET and POST requests can be syntactically equivalent... consider

GET /myscript.php?param=val HTTP/1.1
Host: mysite.com

versus

POST /myscript.php?param=val HTTP/1.1
Host: mysite.com

The script, in fact, is called in exactly the same way. The difference is entirely semantic - POST requests are expected to "do something", while GETs are supposed to be safe always.

But, POST can also include a body. GET cannot - you can only pass what you fit in the URL. This allows file uploads, and so on, that a GET couldn't possibly do. Specifically, using the multipart/form-data encoding, you can send otherwise-unencoded binary data.

Is that what you were asking?

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