目录

 

application/x-www-form-urlencoded

multipart/form-data

text/plain


 

application/x-www-form-urlencoded

请求头中有content-type数据:

一般在表单中填写enctype:

其中enctype有如下的几种:

            1. application/x-www-form-urlencoded

            2. multipart/form-data

            3. text/plain

这个是浏览器自动生成的数据请求!

 

如下的HTML:

<html>
<head>
<title>CSDN IT1995</title>
</head>

<body>
<form action="/form" method="POST" enctype="application/x-www-form-urlencoded">
	<input type="text" name="name">
	<input type="password" name="password">
	<input type="submit">
</form>
</body>

</html>

运行截图如下:

填好表单后:

HTTP之content-type相关

这里把这两个都勾上:

HTTP之content-type相关

点击提交:

HTTP之content-type相关

可以看到当Content-Type:application/x-www-form-urlencoded时,form表单数据如下:

点击原始后:

HTTP之content-type相关

这个application/x-www-form-urlencoded只是把GET方法放到url中的放到body里面罢了!

 

 

multipart/form-data

把enctype修改为:multipart/form-data后,源码如下:

<html>
<head>
<title>CSDN IT1995</title>
</head>

<body>
<form action="/form" method="POST" enctype="multipart/form-data">
	<input type="text" name="name">
	<input type="password" name="password">
	<input type="submit">
</form>
</body>

</html>

再次提交表单看看:

HTTP之content-type相关

发现浏览器默认加了一个boundary,然后在Request Payload里面,以这个为边界进行划分,并且还带上了表单的name。突然间感觉,又掉巧妙啊!

 

text/plain

把enctype修改如下:text/plain

源码如下:

<html>
<head>
<title>CSDN IT1995</title>
</head>

<body>
<form action="/form" method="POST" enctype="text/plain">
	<input type="text" name="name">
	<input type="password" name="password">
	<input type="submit">
</form>
</body>

</html>

提交表单后:

HTTP之content-type相关

从中可以知道这个text/plain还是很常规的。

相关文章:

  • 2022-12-23
  • 2021-04-12
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2021-08-19
猜你喜欢
  • 2021-07-30
  • 2022-01-11
  • 2022-02-21
  • 2021-05-17
  • 2021-06-03
  • 2021-08-05
相关资源
相似解决方案