blob: 0cfc53b2c3e401ad7834b831f670fed7da4bd6c6 (
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
29
30
31
|
/**
* Renders the HTTP Referer header up to the second path slash.
* Used in browser_referrer_*.js, bug 1113431.
*/
function handleRequest(request, response)
{
let referrer = "";
try {
referrer = request.getHeader("referer");
} catch (e) {
referrer = "";
}
// Strip it past the first path slash. Makes tests easier to read.
referrer = referrer.split("/").slice(0, 4).join("/");
let html = `<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
<title>Test referrer</title>
</head>
<body>
<div id='testdiv'>${referrer}</div>
</body>
</html>`;
response.setHeader("Cache-Control", "no-cache", false);
response.setHeader("Content-Type", "text/html", false);
response.write(html);
}
|