Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to setup a web-server (or other kind of server?) that will allow clients to download a file using http. However, I want to start serving the file before it has been fully written to disk.

Ideally, the server would send as much data as is available, and then slow down till more data is ready.

As far as the browser is concerned, this should look like a "regular" download, however the content-length will not be known at start. Is this ok?

Any recommendations how to setup such a server?

share|improve this question

As far as the HTTP Client is concerned it's perfectly fine to not send a Content-length header (though the client won't be able to display a progress bar, just "I've downloaded X Kb, and I have no idea how much is left".

The server side is more difficult. The only way I can think of doing this would be to attach to the file as a stream (using a programming language - PHP, a CGI script, etc.) and return the contents. The problem comes with determining when the file is "done" being written to disk (so you can tell the HTTP client it doesn't have to wait anymore).
There are ways around this, but that programming is left as an exercise for the reader :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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