Should a “multipart/form-data” POST request actual

2020-03-01 18:08发布

I'm creating some performance tests for a web application that sends requests of the same type that a browser would send to our server. One of these requests is a POST that uploads an image. I looked at this question where it looks like the actual contents of the image file should be inside the body of the request. However when I use F12 dev tools in Chrome to inspect what the browser sends in the request it looks like this:

  ------WebKitFormBoundaryjHN86sGb89n2HUZOT
  Content-Disposition: form-data; name="profileImg[]"; filename="bmp.bmp"
  Content-Type: image/bmp


  ------WebKitFormBoundaryjHN86sGb89n2HUZOT--

The space where I expected to see the file contents is blank. I was expecting to see some string of seemingly random characters representing the contents of the image file. There's also no path to the image in the request, only the name of the file, so I can't understand exactly how the file could be uploaded? Is Chrome just hiding the data from me?

2条回答
一纸荒年 Trace。
2楼-- · 2020-03-01 18:45

So I downloaded Fiddler and it actually shows that there is data being sent where we in Chrome see only a blank space. This means that Chrome does indeed hide the data.

查看更多
聊天终结者
3楼-- · 2020-03-01 18:58

Chrome hides the file data, when viewing the request payload using dev tools, for performance reasons:

https://groups.google.com/forum/#!topic/google-chrome-developer-tools/FaInquBDhU0

查看更多
登录 后发表回答