Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
2 function handleRequest(request, response)
3 {
4 // get the Content-Type to serve from the query string
5 var contentType = null;
6 request.queryString.split('&').forEach( function (val) {
7 var [name, value] = val.split('=');
8 if (name == "type") {
9 contentType = unescape(value);
10 }
11 });
13 // avoid confusing cache behaviors
14 response.setHeader("Cache-Control", "no-cache", false);
16 switch (contentType) {
17 case "iframe":
18 response.setHeader("Content-Type", "text/html", false);
19 response.write("frame content");
20 break;
22 case "script":
23 response.setHeader("Content-Type", "application/javascript", false);
24 break;
26 case "stylesheet":
27 response.setHeader("Content-Type", "text/css", false);
28 break;
30 case "object":
31 response.setHeader("Content-Type", "application/x-test", false);
32 break;
34 case "xhr":
35 response.setHeader("Content-Type", "text/xml", false);
36 response.setHeader("Access-Control-Allow-Origin", "https://example.com");
37 response.write('<?xml version="1.0" encoding="UTF-8" ?><test></test>');
38 break;
40 default:
41 response.setHeader("Content-Type", "text/html", false);
42 response.write("<html><body>Hello World</body></html>");
43 break;
44 }
45 }