summaryrefslogtreecommitdiffstats
path: root/netwerk/cookie/test/browser/chips.sjs
blob: e60109f6fa81e16af1b56bc56d7f1706191a0e60 (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
28
function handleRequest(aRequest, aResponse) {
  aResponse.setStatusLine(aRequest.httpVersion, 200);

  var params = new URLSearchParams(aRequest.queryString);

  // Get Cookie header string.
  if (params.has("get")) {
    if (aRequest.hasHeader("Cookie")) {
      let cookie = aRequest.getHeader("Cookie");
      aResponse.write(cookie);
    }
    return;
  }

  // Set a partitioned and a unpartitioned cookie.
  if (params.has("set")) {
    aResponse.setHeader(
      "Set-Cookie",
      "cookie=partitioned; Partitioned; SameSite=None; Secure",
      true
    );
    aResponse.setHeader(
      "Set-Cookie",
      "cookie=unpartitioned; SameSite=None; Secure",
      true
    );
  }
}