// Custom *.sjs file specifically for the needs of Bug 1286861 // small red image const IMG = atob( "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12" + "P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" ); // https://stackoverflow.com/questions/17279712/what-is-the-smallest-possible-valid-pdf const PDF = `%PDF-1.0 1 0 obj<>endobj 2 0 obj<>endobj 3 0 obj<>endobj trailer<>`; function getSniffableContent(type) { switch (type) { case "xml": return ``; case "html": return ` Test test `; case "css": return `*{ color: pink !important; }`; case "json": return `{ 'test':'yes' }`; case "img": return IMG; case "pdf": return PDF; } return "Basic UTF-8 Text"; } function handleRequest(request, response) { let query = new URLSearchParams(request.queryString); // avoid confusing cache behaviors (XXXX no sure what this means?) response.setHeader("X-Content-Type-Options", "nosniff"); // Disable Sniffing response.setHeader("Content-Type", query.get("mime")); response.write(getSniffableContent(query.get("content"))); }