file_bug_1725646_b.sjs (867B)
1 "use strict"; 2 /* eslint-disable @microsoft/sdl/no-insecure-url */ 3 4 const URL_A = 5 "http://example.com/tests/dom/security/test/https-first/file_bug_1725646_a.sjs"; 6 const URL_B = 7 "http://example.com/tests/dom/security/test/https-first/file_bug_1725646_b.sjs"; 8 9 const RESPONSE = ` 10 <!DOCTYPE html> 11 <html> 12 <body> 13 <h1>We don't support HTTPS :(</h1> 14 <p>You will be redirected</p> 15 <script type="application/javascript"> 16 window.opener.postMessage({ location: location.href }, "*"); 17 setTimeout(() => { 18 window.location = "${URL_A}"; 19 }); 20 </script> 21 </body> 22 </html> 23 `; 24 25 function handleRequest(request, response) { 26 response.setHeader("Cache-Control", "no-cache", false); 27 28 if (request.scheme === "http") { 29 response.write(RESPONSE); 30 } else { 31 response.setStatusLine(request.httpVersion, 302, "Found"); 32 response.setHeader("Location", URL_B, false); 33 } 34 }