michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const { classes: Cc, interfaces: Ci } = Components; michael@0: michael@0: function handleRequest(request, response) { michael@0: response.processAsync(); michael@0: michael@0: let params = request.queryString.split("&"); michael@0: let index = params.filter((s) => s.contains("index="))[0].split("=")[1]; michael@0: michael@0: let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); michael@0: timer.initWithCallback(() => { michael@0: // to avoid garbage collection michael@0: timer = null; michael@0: response.setStatusLine(request.httpVersion, index == 1 ? 101 : index * 100, "Meh"); michael@0: response.setHeader("Content-Type", "text/" + index, false); michael@0: response.write(new Array(index * 10).join(index)); // + 0.01 KB michael@0: response.finish(); michael@0: }, 10, Ci.nsITimer.TYPE_ONE_SHOT); // Make sure this request takes a few ms. michael@0: }