当前位置:网站首页>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
边栏推荐
- Huawei certified cloud computing hica
- 轻量级计划服务工具研发与实践
- Final review of information and network security (based on the key points given by the teacher)
- [VNCTF 2022]ezmath wp
- 03 products and promotion developed by individuals - plan service configurator v3.0
- 【MMdetection】一文解决安装问题
- Akamai 反混淆篇
- Xin'an Second Edition: Chapter 24 industrial control safety demand analysis and safety protection engineering learning notes
- Program counter of JVM runtime data area
- Wordcloud colormap color set and custom colors
猜你喜欢

Final review of information and network security (full version)

轻量级计划服务工具研发与实践

C#版Selenium操作Chrome全屏模式显示(F11)

1. Introduction to JVM

Serial serialold parnew of JVM garbage collector

Akamai浅谈风控原理与解决方案

【Elastic】Elastic缺少xpack无法创建模板 unknown setting index.lifecycle.name index.lifecycle.rollover_alias

Flink analysis (I): basic concept analysis

自动答题 之 Selenium测试直接运行在浏览器中,就像真正的用户在操作一样。

C # nanoframework lighting and key esp32
随机推荐
自动化运维利器ansible基础
DataGridView scroll bar positioning in C WinForm
Display picture of DataGridView cell in C WinForm
Concept and basic knowledge of network layering
CTF逆向入门题——掷骰子
Openharmony developer documentation open source project
mysql 基本增删改查SQL语句
Garbage first of JVM garbage collector
mysql高级(索引,视图,存储过程,函数,修改密码)
[ASM] introduction and use of bytecode operation classwriter class
Essai de pénétration du Code à distance - essai du module b
connection reset by peer
Junit单元测试
Xin'an Second Edition; Chapter 11 learning notes on the principle and application of network physical isolation technology
轻量级计划服务工具研发与实践
C# WinForm系列-Button简单使用
C # nanoframework lighting and key esp32
Redis quick start
The most complete tcpdump and Wireshark packet capturing practice in the whole network
全网最全tcpdump和Wireshark抓包实践