2011-07-05 18:40:00 -07:00
|
|
|
var timer = null; // declare timer outside to prevent premature GC
|
2010-03-08 09:16:35 -08:00
|
|
|
function handleRequest(request, response)
|
|
|
|
{
|
|
|
|
response.processAsync();
|
|
|
|
response.setHeader("Content-Type", "text/plain", false);
|
|
|
|
|
|
|
|
for (var i = 0; i < 1000; ++i)
|
|
|
|
response.write("Hello... ");
|
|
|
|
|
2011-07-05 18:40:00 -07:00
|
|
|
timer = Components.classes["@mozilla.org/timer;1"]
|
2010-03-08 09:16:35 -08:00
|
|
|
.createInstance(Components.interfaces.nsITimer);
|
|
|
|
timer.initWithCallback(function() {
|
|
|
|
response.write("world.\n");
|
|
|
|
response.finish();
|
|
|
|
}, 10 * 1000 /* 10 secs */, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
|
|
|
}
|