简体   繁体   中英

How's file downloaded by the browser over HTTP

我目前正在尝试准确地了解当浏览器将文件下载到桌面时会发生什么情况,特别是使用了多少个HTTP请求,该过程与仅获取图像或脚本之类的资源有何不同。等等。如果有人从这里开始设计一个进程,则A browser sends HTTP request

  1. A Browser sends an http request
  2. The server responds with the file to be downloaded, and adds some HTTP headers (which say that it's a file to be downloaded) usually along these lines: Content-Type: application/octet-stream Content-Disposition: attachment; filename="picture.png" Content-Type: application/octet-stream Content-Disposition: attachment; filename="picture.png"
  3. The Browser then handles the response according to user settings (usually asks for permission before saving)

I know it's a bit of reading, but this is a good resource. Also, for a less intense introduction this helped me out quite a bit.

As to the number of HTTP requests used the answer is one. There is a TCP handshake done then the request is transmitted, after that the response is sent back. There is a little more involved if everything is over SSL/TLS, but that's all part of one HTTP request/response cycle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM