您的位置:首页 > 理论基础 > 计算机网络

Http post请求 entity body的格式

2016-10-05 10:45 211 查看
Http post请求 entity body的格式,有三种格式,具体使用哪一种,由消息头当中ContentType的值所决定

1. ContentType:multipart/form-data; boundary=

如:上传文件

POST /api/feed/ HTTP/1.1

Accept-Encoding: gzip

Content-Length: 225873

Content-Type: multipart/form-data; boundary=OCqxMF6-JxtxoMDHmoG5W5eY9MGRsTBp

Host: www.myhost.com

Connection: Keep-Alive

–OCqxMF6-JxtxoMDHmoG5W5eY9MGRsTBp

Content-Disposition: form-data; name=”lng”

Content-Type: text/plain; charset=UTF-8

Content-Transfer-Encoding: 8bit

116.361545

–OCqxMF6-JxtxoMDHmoG5W5eY9MGRsTBp

Content-Disposition: form-data; name=”lat”

Content-Type: text/plain; charset=UTF-8

Content-Transfer-Encoding: 8bit

39.979006

–OCqxMF6-JxtxoMDHmoG5W5eY9MGRsTBp

Content-Disposition: form-data; name=”images”; filename=”/storage/emulated/0/Camera/jdimage/1xh0e3yyfmpr2e35tdowbavrx.jpg”

Content-Type: application/octet-stream

Content-Transfer-Encoding: binary

这里是图片的二进制数据

–OCqxMF6-JxtxoMDHmoG5W5eY9MGRsTBp–

ContentType:x-www-form-urlencoded

如:

POST http://www.example.com HTTP/1.1

Content-Type: application/x-www-form-urlencoded;charset=utf-8

title=test&sub%5B%5D=1&sub%5B%5D=2&sub%5B%5D=3

【参考】

1. 关于application/x-www-form-urlencoded等字符编码的

http://blog.sina.com.cn/s/blog_5f1fe33f0100e65s.html

2. postman中 form-data、x-www-form-urlencoded、raw、binary的区别

http://blog.csdn.net/ye1992/article/details/49998511

3.四种常见的 POST 提交数据方式

https://imququ.com/post/four-ways-to-post-data-in-http.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: