javascript - How's file downloaded by the browser over HTTP - Stack Overflow

I'm currently trying to understand precisely what happens when a browser downloads a file to deskt

I'm currently trying to understand precisely what happens when a browser downloads a file to desktop, specifically how many HTTP requests are used, how the process is different to just getting a resource like an image or script, etc. I'd be grateful if anyone laid out a process here starting from A browser sends HTTP request.

I'm currently trying to understand precisely what happens when a browser downloads a file to desktop, specifically how many HTTP requests are used, how the process is different to just getting a resource like an image or script, etc. I'd be grateful if anyone laid out a process here starting from A browser sends HTTP request.

Share Improve this question edited Oct 12, 2015 at 6:55 Max Koretskyi asked Oct 12, 2015 at 6:41 Max KoretskyiMax Koretskyi 106k68 gold badges353 silver badges516 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6
  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"
  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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744124281a4559543.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信