in reply to Threading http file transfers

There is no point in having multiple output threads serving a single HTTP request. There might be some benefit to having one thread handle any calculation (creating the zip files) and another sending the data back to the client.

Download accelerators work by dividing the file into ranges and requesting each range in a separate connection. The easiest way to serve these requests is cache the zip file on disk. Create it on the first request and serve the proper ranges on later requests. It might even be possible to allow the web server to serve the zip file and only call your script when it doesn't exist.

The other option is for each request to create the zip file, serve the range requested, and then delete the temporary file.