Pushing Back on Y2K
By Randal L. Schwartz
Almost every day, I hear another story in the popular or industry press about Y2K: Meeting Y2K compliance for air traffic control. Y2K concerns about the power grid. And of course, a frequently asked question about Perl is "does the <fill in the blank> Perl module handle Y2K properly?" Well, ultimately, who knows? But meanwhile, I've got some code to hack out.
One of the things that seem to be popping up everywhere is the cute, little Y2K countdown clock. For the most part, they seem to be Java or JavaScript toys, all completely useless after the turn of the century. So, it occurred to me that I could write one of these gadgets without resorting to the overkill of using a low-level language like Java or JavaScript. At the same time, I could show off how to create a dynamically changing image using "server push" technology -- something most modern browsers understand just fine -- without enabling security-risky and destabilizing add-on techniques.
Now, most of the things that server push had been used for have been subsumed by the proper creation of "animated GIFs," but animated GIFs work only when all the images can be predetermined before the download. In the case of the Y2K clock, we need to compute each image individually, because the clock never displays the same numbers twice.
In order to use a server-push script, we have to adhere to a few restrictions. One is that we'll need to generate a repeated set of HTTP headers and bodies, all within a structure that gives the overall content-type of multipart/x-replace-mixed.