HTTP请求中的form data和request payload的区别

时间:2022-08-22 18:03:28

当表单的enctype不写或写"application/x-www-form-urlencoded"时,请求发的是form data

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="" method="post" enctype="application/x-www-form-urlencoded">
<input type="text" name="aaaabbbb">
<input type="submit" name="">
</form>
</body>
</html>

打开chrome的调试,可以看到提交后的数据为

HTTP请求中的form data和request payload的区别

当表单的enctype写其他时,比如"multipart/form-data"或"text/plain",请求时发送的是request payload

        <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="text" name="aaabbb">
<input type="text" name="cccddd">
<input type="submit" name="">
</form>
</body>
</html>

HTTP请求中的form data和request payload的区别

 

打开chrome的调试,可以看到请求的数据,其中boundary是分隔符

HTTP请求中的form data和request payload的区别