如何在HTTP POST请求中发送参数? [英] How are parameters sent in an HTTP POST request?
问题描述
在HTTP GET 请求中,参数将作为 查询字符串 发送:
http://example.com/page ?parameter = value&also = another
在HTTP POST 请求中,参数不会与URI一起发送。
值? 在请求标头中?在请求正文中?它是什么样的?
这些值在请求正文中以内容类型指定的格式发送。 / p>
通常内容类型是 application / x-www-form-urlencoded
,因此请求正文使用相同的格式作为查询字符串:
parameter = value& also = another
当您在表单中使用文件上传时,使用 multipart / form-data
编码,有不同的格式。它更复杂,但你通常不需要关心它的样子,所以我不会展示一个例子,但知道它存在就好了。
In an HTTP GET request, parameters are sent as a query string:
http://example.com/page?parameter=value&also=another
In an HTTP POST request, the parameters are not sent along with the URI.
Where are the values? In the request header? In the request body? What does it look like?
The values are sent in the request body, in the format that the content type specifies.
Usually the content type is application/x-www-form-urlencoded
, so the request body uses the same format as the query string:
parameter=value&also=another
When you use a file upload in the form, you use the multipart/form-data
encoding instead, which has a different format. It's more complicated, but you usually don't need to care what it looks like, so I won't show an example, but it can be good to know that it exists.
这篇关于如何在HTTP POST请求中发送参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!