xpinstall/tests/cookieRedirect.sjs
author Boris Zbarsky <bzbarsky@mit.edu>
Wed, 09 Nov 2011 16:11:39 -0500
changeset 80106 5636969704cdf56c5918f655e051cd7c38cd1c34
parent 24957 e321d96f814530a34062cf864e2927480f27a005
permissions -rw-r--r--
Bug 699528. Make pausing/unpausing JSD try to turn off/on debug mode as needed. r=sfink The new boolean argument to SetDebugModeWhenPossible is needed because if we allow sync-disable of debug mode we seem to crash when loading pages with Firebug active.

// Simple script redirects to the query part of the uri if the cookie "xpinstall"
// has the value "true", otherwise gives a 500 error.

function handleRequest(request, response)
{
  let cookie = null;
  if (request.hasHeader("Cookie")) {
    let cookies = request.getHeader("Cookie").split(";");
    for (let i = 0; i < cookies.length; i++) {
      if (cookies[i].substring(0, 10) == "xpinstall=")
        cookie = cookies[i].substring(10);
    }
  }

  if (cookie == "true") {
    response.setStatusLine(request.httpVersion, 302, "Found");
    response.setHeader("Location", request.queryString);
    response.write("See " + request.queryString);
  }
  else {
    response.setStatusLine(request.httpVersion, 500, "Internal Server Error");
    response.write("Invalid request");
  }
}