What actions does the IE take when we right click the following URL and choose “Save as”?
http://www.somesite.com/some_file.zip
I heard of something like “HTTP Download”, what exactly is it?
My understanding is, HTTP is a text based protocol, how could it be used to transfer different kinds of files?
My guess is, when we choose Save as for a URL, IE (or any other browser) will open a new TCP connection to the server and do the file transfer. It should have nothing to do with HTTP.
- When we visit a web page, browser use TCP connection to transfer HTTP
info and HTMLs. - When we download file in IE, browser use TCP to transfer file content.
It’s essentially the same, only differnt in what’s being transfered.
Am I right?
connection to tranfer file content.
You could transfer any binary data over HTTP. For example the server could set the
Content-Typeresponse header to anything and then write any data to the response. So for example you could set theContent-Typetoapplication/octet-streamand then write binary data to the response. So what IE does is that it analyzes the Content-Type response header, downloads the contents and if it is a known content type that it can display (such as HTML for example) it displays it inline, if not, it prompts the user to save it.HTTP is not a text based protocol. The headers should be text but the body of the request/response could be arbitrary bytes. That’s what the headers are used for: to indicate exactly how is the body encoded so that the other party could understand and decode it appropriately.
As far as TCP and HTTP are concerned, HTTP is a protocol on the top of TCP. So when using HTTP you are implicitly using TCP. Think of it as a convention based protocol over the main transmition mechanism which is TCP. TCP is low level: it is what allows the connection between the client and the server. HTTP is like a language. Without HTTP, TCP is like two people from different countries, each speaking a different language, meeting in a bar. What do you think will happen? They won’t be able to exchange a word. HTTP is the common language that unites them and allows them to talk. TCP is just the bar.