当前位置:网站首页>How to submit data through post
How to submit data through post
2022-07-06 17:38:00 【Wzzzzzzx】
When it comes to uploading data , We will naturally say Json/XML
, But these are data formats . But the way of data uploading has been ignored by me all the time . The current understanding is , Four common schemes are commonly used to encode local data , adopt Content-Type
To specify the data upload method , At the same time through Content-Length
To specify the data length .
application/x-www-form-urlencoded
This should be the most common way to submit . In native forms From
, If not set enctype
attribute , This scheme will be adopted by default to upload data . Its HTTP
The requested information is as follows :
POST http://www.example.com HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=utf-8
titile=%E6%B5%8B%E8%AF%95&body=%E6%B5%8B%E8%AF%95
It can be seen that ,Body
Part of the data goes through URL
After transcoding , With key1=val1&key2=val2
In the form of . In many cases , This is all Post
Default submission method , But because it uses three characters to represent a Non-ASCII
character , So the efficiency is relatively low .
multipart/form-data
Form enctype
Attribute currently has two attribute values , One default is application/x-www-form-urlencoded
, The other way is multipart/form-data
了 . This sending method is designed to support sending binary data to the server . Its HTTP
The requested information is as follows :
POST http://www.example.com HTTP/1.1
Content-Type:multipart/form-data; boundary=aHR0cDovL3d3dy5leGFtcGxlLmNvbQ
--aHR0cDovL3d3dy5leGFtcGxlLmNvbQ
Content-Disposition: form-data; name="city"
Test
--aHR0cDovL3d3dy5leGFtcGxlLmNvbQ
Content-Disposition: form-data; name="file"; filename="test.png"
Content-Type: image/png
Content-Transfer-Encoding: binary
PNG ... content of test.png ...
--aHR0cDovL3d3dy5leGFtcGxlLmNvbQ--
As you can see from the above example , The format of this sending method includes multiple Part
, Every Part
Use randomly generated --boundary
To segment , The last line uses --boundary--
ending . Every Part
Must contain a Content-Disposition
Field , This field contains a type
and name
Parameters of , If there are files uploaded , We need another one filename
Parameters of , among type
The value is form-data
. Here you can also see the sending pictures Part
It also uses Content-Type
, If it can be the type of binary file when sending , Then the corresponding type value will be filled , If you can't recognize it , Will adopt application/octet-stream
As type value , If multiple documents are summarized into one form item , Will use multipart/mixed
As attribute value . At the same time , If Part
The content of is the same as the default encoding
In a different way , Will have a Content-Transfer-Encoding
Property to specify the Part
Coding method of .
application/json
and text/xml
These two methods can be seen from the name of its transmission content , Not much .
Reference resources
https://imququ.com/post/four-ways-to-post-data-in-http.html
https://www.jianshu.com/p/29e38bcc8a1d
边栏推荐
- Quick start of Hongmeng system
- Final review of information and network security (full version)
- Xin'an Second Edition: Chapter 26 big data security demand analysis and security protection engineering learning notes
- C WinForm series button easy to use
- The problem of "syntax error" when uipath executes insert statement is solved
- 分布式(一致性协议)之领导人选举( DotNext.Net.Cluster 实现Raft 选举 )
- Essai de pénétration du Code à distance - essai du module b
- Grafana 9 is officially released, which is easier to use and more cool!
- 【MySQL入门】第四话 · 和kiko一起探索MySQL中的运算符
- C # nanoframework lighting and key esp32
猜你喜欢
CTF reverse entry question - dice
[reverse intermediate] eager to try
Huawei certified cloud computing hica
【逆向初级】独树一帜
Models used in data warehouse modeling and layered introduction
06 products and promotion developed by individuals - code statistical tools
PySpark算子处理空间数据全解析(5): 如何在PySpark里面使用空间运算接口
Flink parsing (VII): time window
JVM garbage collector part 1
华为认证云计算HICA
随机推荐
MySQL error reporting solution
02个人研发的产品及推广-短信平台
灵活报表v1.0(简单版)
沉淀下来的数据库操作类-C#版(SQL Server)
The most complete tcpdump and Wireshark packet capturing practice in the whole network
【MySQL入门】第一话 · 初入“数据库”大陆
Interpretation of Flink source code (II): Interpretation of jobgraph source code
【MySQL入门】第三话 · MySQL中常见的数据类型
Wu Jun trilogy insight (IV) everyone's wisdom
February database ranking: how long can Oracle remain the first?
Wu Jun's trilogy experience (VII) the essence of Commerce
JUnit unit test
学 SQL 必须了解的 10 个高级概念
C# WinForm中DataGridView单元格显示图片
[VNCTF 2022]ezmath wp
Interpretation of Flink source code (I): Interpretation of streamgraph source code
04 products and promotion developed by individuals - data push tool
自动答题 之 Selenium测试直接运行在浏览器中,就像真正的用户在操作一样。
Vscode replaces commas, or specific characters with newlines
[ciscn 2021 South China]rsa writeup