summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/browser/redirect_self.sjs
blob: 953afe5f26c885d09e4cca12f6cb337a81065d66 (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
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

// Script that redirects to itself once.

function handleRequest(request, response) {
  if (
    request.hasHeader("Cookie") &&
    request.getHeader("Cookie").includes("redirect-self")
  ) {
    response.setStatusLine("1.0", 200, "OK");
    // Expire the cookie.
    response.setHeader(
      "Set-Cookie",
      "redirect-self=true; expires=Thu, 01 Jan 1970 00:00:00 GMT",
      true
    );
    response.setHeader("Content-Type", "text/plain; charset=utf-8", false);
    response.write("OK");
  } else {
    response.setStatusLine(request.httpVersion, 302, "Moved Temporarily");
    response.setHeader("Set-Cookie", "redirect-self=true", true);
    response.setHeader("Location", "redirect_self.sjs");
    response.write("Moved Temporarily");
  }
}