3 const BinaryOutputStream = Components.Constructor(
4 "@mozilla.org/binaryoutputstream;1",
5 "nsIBinaryOutputStream",
9 // this is simply a hex dump of a red square .PNG image
13 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00,
14 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20,
15 0x00, 0x00, 0x00, 0x20, 0x08, 0x02, 0x00, 0x00, 0x00, 0xFC,
16 0x18, 0xED, 0xA3, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47,
17 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, 0x00, 0x28,
18 0x49, 0x44, 0x41, 0x54, 0x48, 0xC7, 0xED, 0xCD, 0x41, 0x0D,
19 0x00, 0x00, 0x08, 0x04, 0xA0, 0xD3, 0xFE, 0x9D, 0x35, 0x85,
20 0x0F, 0x37, 0x28, 0x40, 0x4D, 0x6E, 0x75, 0x04, 0x02, 0x81,
21 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0xC1, 0x93, 0x60, 0x01,
22 0xA3, 0xC4, 0x01, 0x3F, 0x58, 0x1D, 0xEF, 0x27, 0x00, 0x00,
23 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82
26 function handleRequest(request, response) {
28 request.queryString.split("&").forEach(function (val) {
29 let [name, value] = val.split("=");
30 query[name] = unescape(value);
33 response.setHeader("Cache-Control", "no-cache");
35 response.setStatusLine(request.httpVersion, 200, "OK");
36 response.setHeader("Content-Type", "text/plain", false);
38 let log = getState("bug-879963-request-log") || "";
40 let stream = new BinaryOutputStream(response.bodyOutputStream);
42 if (query.q == "init") {
43 log = "init"; // initialize the log, and return a PNG image
44 response.setHeader("Content-Type", "image/png", false);
45 stream.writeByteArray(RED_SQUARE);
46 } else if (query.q == "image") {
47 log = log + ";" + query.q;
48 response.setHeader("Content-Type", "image/png", false);
49 stream.writeByteArray(RED_SQUARE);
50 } else if (query.q == "font") {
51 log = log + ";" + query.q;
52 // we don't provide a real font; that's ok, OTS will just reject it
53 response.write("Junk");
54 } else if (query.q == "report") {
55 // don't include the actual "report" request in the log we return
58 log = log + ";" + query.q;
59 response.setStatusLine(request.httpVersion, 404, "Not Found");
62 setState("bug-879963-request-log", log);