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
.
1 Answer
Reset to default 6- A Browser sends an http request
- 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"
- 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条)