2

When a non-HTML file such as a PDF, DOCX, EXE, etc is made public to the WWW by an HTTP server, and a client makes a request for said file,

www.example.com/download?=test.doc

what facilitates the file transfer over to the client?

Is it transmitted over HTTP or another protocol? In what format or encoding is the data represented?

I'd also like to know how some file download implementations can transmit the file and simultaneously send a HTTP response back containing just the header (eg, content-disposition) which indicates to me that the empty response body was not the vessel for the file.

0

1 Answer 1

5

Yes it is transferred by HTTP. Your example url kind of obscures the fact because you have left out the scheme (the initial "http:"), but if you enter an url without a scheme in a web browser, it will default to http, hence the url is actually:

http://www.example.com/download?=test.doc

A HTTP response contains a header and a payload, and the payload can be data in any format - html, javascript, css, images, or any other file format including doc or exe. At the HTTP level, a HTML payload and a DOC payload are treated exactly the same. On the client side they will of course be treated differently - html or images will be rendered in the browser while a doc will (depending on configuration) cause the browser to launch an external application like Word. But this is at the discretion of the client, and is outside the scope of http.

The content disposition header does not really change how the payload is transferred via http, it it just a hint to the client how the handle the payload when received. It can indicate that the user should be prompted to save the payload as a local file, rather then rendering/processing the payload as is the default. But the transfer mechanism is the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.