The special CGI script below will send every file in the requested directory to the client's web browser, with each document replacing the one before it. A technology similar to this is used at The United Space Alliance to provide real-time video feeds of NASA-TV in your web browser. No plugins are required to receive the video. Also, take a look at Netscape's Amazing, Continuously Refreshing Fish Cam.
These examples make use of the MIME type "multipart/x-mixed-replace" to encapsulate many different files into one. This has been working fine in Netscape since version 1.1. Unfortunately, Microsoft's Internet Explorer 3.0 does not support it. (Maybe 4.0 does... but who's upgraded to that behemoth?)
We'll be using the following content-type header: Content-type: multipart/x-mixed-replace; boundary=xstringx
Each part will be delimited with the string "xstringx". For obvious reasons, this string should not appear in any of the output documents. It should be noted that each part of the multipart document will replace the previous one in the web browser. So, the data sent by the web browser will be the following:
Expires: Thu, 1 Jan 1998 00:00:00 GMT
Content-type: multipart/x-mixed-replace; boundary=xstringx
JPEG IMAGE STREAM GOES HERE
GIF IMAGE STREAM GOES HERE
Hi. This is a sample plain text file
To use the script below, you'll need to implement a called "non-parsed" CGIs on your site. Normally, the web server will buffer all output from your CGI program until it the program finishes. We don't want that to happen here. With Apache, it's quite easy. If the name of your CGI program starts with "nph-" it won't be parsed. Also, change the glob "/some/path/*" to the path where you want to look for files.
Notice how the content types are determined by the file's extension is .html, .txt, .jpeg, .jpg, or .gif. Modern web servers may use other techniques to really what is really inside each file.
If the user hits the STOP button, the HTTP connection will be broken and the Perl script will terminate. You should note that while this script is running, your server has a connection open. This shouldn't be a problem on most web servers which can handle many simultaneous connections.
thing to explore is what happens when the data stream is
saved to disk. Try it out by right-clicking on "try it out" and
then choose save to disk. What ends up in the file might