A body of type POST can contain any content format, and the browser can parse the request body based on the content-Type specified in the request header. Here’s how Postman simulates four typical request bodies. A form-data is multipart/form-data, which organizes the form’s data into key-value form and processes it into a message using the delimiter boundary (boundary can be arbitrarily set). Due to boundary isolation, both files and parameters can be uploaded.
[AppleScript] _ Plain text view _ copy code _
?
01
02
03
04
05
06
07
08
09
10
11
12
13
POST HTTP ` / ` 1.1
Host
`:
test.app.com`
Cache
`-Control
:
no-
cache`
Postman
`-Token
:
59227787-
c438
-361d
–fbe
1-75
feeb78047
e`
Content
`-Type
:
multipart/
form-
data; boundary
=`----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content`-Disposition: form-data; ` `name=”filekey”; filename=””`
Content
`-Type
:`
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content`-Disposition: form-data; ` `name=`”textkey”
tttttt
------WebKitFormBoundary7MA4YWxkTrZu0gW--
The boundary parameter in the request body specifies the separator. It can be seen that the request content is divided into two sections, the first corresponding to filekey and the second corresponding to TextKey. X-www-form-urlencoded, i.e. application/ X-www-from-urlencoded, will convert the data in a form into key-value.
?
1
2
3
4
5
6
7
POST HTTP ` / ` 1.1
Host
`:
test.app.com`
Content
`-Type
:
application/
x-
www-
form-
urlencoded`
Cache
`-Control
:
no-
cache`
Postman
`-Token
:
e00
dbaf5
-15e
8-3667
-6fc
5-48
ee3
cc`89758
key
`1=
value1
&key
2=
value`2
Three raw can upload any format [text], you can upload text, JSON, XML, HTML, etc. Such as json
?
1
2
3
4
5
6
7
POST HTTP ` / ` 1.1
Host
`:
test.app.com`
Content
`-Type
:
application/
json`
Cache
`-Control
:
no-
cache`
Postman
`-Token
:
05a
064d
2-
fa79
-10c
0-
caba-15
ca5
d1
a940
f`
{
`”key1″:
“value1”,
“key2”:
“value2”`}
Binary content-type :application/octet-stream: uploads only binary data, usually files. Since there are no keys, only one file can be uploaded at a time.
?
1
2
3
4
5
6
POST HTTP ` / ` 1.1
Host
`:
test.app.com`
Cache
`-Control
:
no-
cache`
Postman
`-Token
:
5ad
66f
08-6
faa-
aba0
-744a
–ca
958b
1a
0fc
2`
undefined
Five multipart/form-data and X-www-form-urlencoded differences
There are two forms in HTML: Application/X-www-form-urlencoded and multipart/form-data. Application/X-www-form-urlencoded is the default MIME content encoding type,
It is extremely inefficient at transferring large binary or text data.
Multipart /form-data: you can upload binary data, such as files, as well as form key-value pairs, which are converted into a message at the end. When multipart/form-data is set, HTTP ignores the contentType property.
X-www-form-urlencoded: Only key-value pairs can be uploaded, not file uploads