Should a “multipart/form-data” POST request actually contain a string with the data of an uploaded image?

匆匆过客 提交于 2019-12-30 06:26:18

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/54409184/how-can-i-see-submitted-post-request-data-in-chrome-devtools-for-multipart-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!