如何在 HTTP POST 请求中发送参数? [英] How are parameters sent in an HTTP POST request?

查看:55
本文介绍了如何在 HTTP POST 请求中发送参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 HTTP GET 请求中,参数作为查询字符串发送:

In an HTTP GET request, parameters are sent as a query string:

http://example.com/page?parameter=value&also=another

在 HTTP POST 请求中,参数不会与 URI 一起发送.

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.

通常内容类型是application/x-www-form-urlencoded,因此请求体使用与查询字符串相同的格式:

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

当您在表单中使用文件上传时,您使用的是 multipart/form-data 编码,它具有不同的格式.它更复杂,但你通常不需要关心它的样子,所以我不会展示一个例子,但知道它存在会很好.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆