summaryrefslogtreecommitdiffstats
path: root/toolkit/components/antitracking/test/browser/server.sjs
blob: 4d1b2ef01ae2d2d055d77fcf4e636060db57d9fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function handleRequest(aRequest, aResponse) {
  if (aRequest.queryString.includes("redirect")) {
    aResponse.setStatusLine(aRequest.httpVersion, 302);
    if (aRequest.queryString.includes("redirect-checkonly")) {
      aResponse.setHeader("Location", "server.sjs?checkonly");
    } else {
      aResponse.setHeader("Location", "server.sjs");
    }
    return;
  }
  aResponse.setStatusLine(aRequest.httpVersion, 200);
  if (aRequest.hasHeader("Cookie")) {
    aResponse.write("cookie-present");
  } else {
    if (!aRequest.queryString.includes("checkonly")) {
      aResponse.setHeader("Set-Cookie", "foopy=1");
    }
    aResponse.write("cookie-not-present");
  }
}