summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs
blob: 1ce865a8ac4443db16bebebd9ae5bbd69966c9d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function handleRequest(request, response)
{
  var match = request.queryString.match(/^state=(.*)$/);
  if (match)
  {
    response.setStatusLine(request.httpVersion, 200, "No content");
    setState("state", match[1]);
    response.write("state='" + match[1] + "'");
  }

  if (request.queryString == "")
  {
    switch (getState("state"))
    {
      case "": // The default value
        response.setStatusLine(request.httpVersion, 307, "Moved temporarly");
        response.setHeader("Location", "http://example.com/non-existing-dynamic.html");
        response.setHeader("Content-Type", "text/html");
        break;
      case "on":
        response.setStatusLine(request.httpVersion, 200, "OK");
        response.setHeader("Content-Type", "text/html");
        response.write("<html><body>Dynamic page</body></html>");
        break;
    }
  }
}