2011-11-25 06:06:22 +04:00
|
|
|
function parseQuery(request, key) {
|
|
|
|
var params = request.queryString.split('&');
|
|
|
|
for (var j = 0; j < params.length; ++j) {
|
|
|
|
var p = params[j];
|
|
|
|
if (p == key)
|
|
|
|
return true;
|
|
|
|
if (p.indexOf(key + "=") == 0)
|
|
|
|
return p.substring(key.length + 1);
|
|
|
|
if (p.indexOf("=") < 0 && key == "")
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-05-31 02:02:06 +04:00
|
|
|
// Return file content for the first request with a given key.
|
|
|
|
// All subsequent requests return a redirect to a different-origin resource.
|
2009-01-24 14:00:17 +03:00
|
|
|
function handleRequest(request, response)
|
|
|
|
{
|
2011-11-25 06:06:22 +04:00
|
|
|
var domain = parseQuery(request, "domain");
|
|
|
|
var file = parseQuery(request, "file");
|
|
|
|
var allowed = parseQuery(request, "allowed");
|
2010-05-31 02:02:06 +04:00
|
|
|
|
|
|
|
response.setStatusLine(request.httpVersion, 303, "See Other");
|
|
|
|
response.setHeader("Location", "http://" + domain + "/tests/content/media/test/" + (allowed ? "allowed.sjs?" : "") + file);
|
|
|
|
response.setHeader("Content-Type", "text/html");
|
2009-01-24 14:00:17 +03:00
|
|
|
}
|