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