HTTP POST方法的四种Content-Type
四种方式包括:
application/x-www-form-urlencoded (URL encoded)
multipart/form-data (键值对型数据)
application/json (Json 类型数据)
text/xml (xml)
application/x-www-form-urlencoded
其实就和GET方法在URL中添加参数的格式差不多,通过?追加参数,通过:区分键和值,通过&区分不同的键值对。
只是在POST时,把这种参数放在了HTTP Body中。
例如:
网络请求:
POST http://httpbin.org/post HTTP/1.1
Host httpbin.org
User-Agent python-requests/2.24.0
Accept-Encoding gzip, deflate
Accept */*
Content-Length 49
Content-Type application/x-www-form-urlencoded
Connection keep-alive
name=%E8%A5%BF%E5%9B%AD%E5%85%AC%E5%AD%90&age=666 //可以看出汉字是使用utf8编码的
——————
原文连接:[HTTP中POST提交数据的四种方式详解](https://zhuanlan.zhihu.com/p/344743820)
multipart/form-data
这种编码方式,通常是用在客户端向服务端传送大文件数据,如:图片或者文件。
首先来解释下什么它的编码方式,首先会生成一个很长的 boundary 字符串分界