首页 > 其他分享 >What's the difference between "Request Payload" vs "Form Data" as seen in C

What's the difference between "Request Payload" vs "Form Data" as seen in C

时间:2022-11-15 16:26:01浏览次数:80  
标签:What HTTP Network form data Request Content Type Form

 

 

The Request Payload - or to be more precise: payload body of a HTTP Request

A request with Content-Type: application/json may look like this:

POST /some-path HTTP/1.1
Content-Type: application/json

{ "foo" : "bar", "name" : "John" }

If you submit this per AJAX the browser simply shows you what it is submitting as payload body. That’s all it can do because it has no idea where the data is coming from.

If you submit a HTML-Form with method="POST" and Content-Type: application/x-www-form-urlencoded or Content-Type: multipart/form-data your request may look like this:

POST /some-path HTTP/1.1
Content-Type: application/x-www-form-urlencoded

foo=bar&name=John

In this case the form-data is the request payload. Here the Browser knows more: it knows that bar is the value of the input-field foo of the submitted form. And that’s what it is showing to you.

So, they differ in the Content-Type but not in the way data is submitted. In both cases the data is in the message-body. And Chrome distinguishes how the data is presented to you in the Developer Tools.

 

 

 

https://stackoverflow.com/questions/23118249/whats-the-difference-between-request-payload-vs-form-data-as-seen-in-chrome

标签:What,HTTP,Network,form,data,Request,Content,Type,Form
From: https://www.cnblogs.com/leodaxin/p/16892785.html

相关文章