browser/devtools/netmonitor/test/sjs_status-codes-test-server.sjs

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 const { classes: Cc, interfaces: Ci } = Components;
michael@0 5
michael@0 6 function handleRequest(request, response) {
michael@0 7 response.processAsync();
michael@0 8
michael@0 9 let params = request.queryString.split("&");
michael@0 10 let status = params.filter((s) => s.contains("sts="))[0].split("=")[1];
michael@0 11
michael@0 12 let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
michael@0 13 timer.initWithCallback(() => {
michael@0 14 // to avoid garbage collection
michael@0 15 timer = null;
michael@0 16 switch (status) {
michael@0 17 case "100":
michael@0 18 response.setStatusLine(request.httpVersion, 101, "Switching Protocols");
michael@0 19 break;
michael@0 20 case "200":
michael@0 21 response.setStatusLine(request.httpVersion, 202, "Created");
michael@0 22 break;
michael@0 23 case "300":
michael@0 24 response.setStatusLine(request.httpVersion, 303, "See Other");
michael@0 25 break;
michael@0 26 case "400":
michael@0 27 response.setStatusLine(request.httpVersion, 404, "Not Found");
michael@0 28 break;
michael@0 29 case "500":
michael@0 30 response.setStatusLine(request.httpVersion, 501, "Not Implemented");
michael@0 31 break;
michael@0 32 }
michael@0 33 response.setHeader("Content-Type", "text/plain; charset=utf-8", false);
michael@0 34 response.write("Hello status code " + status + "!");
michael@0 35 response.finish();
michael@0 36 }, 10, Ci.nsITimer.TYPE_ONE_SHOT); // Make sure this request takes a few ms.
michael@0 37 }

mercurial