Last active
August 29, 2015 14:04
-
-
Save eborden/e69054ec4c463bfd2f9a to your computer and use it in GitHub Desktop.
Node server to test whether chunked resources are loaded if the head element is partial. Should log: "title: " and "title: stuff"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
http.createServer(function (req, res) { | |
if (req.url == '/script.js') { | |
res.writeHead(200, {'Content-Type': 'text/javascript'}); | |
res.end('console.log("title: " + document.title);' | |
+ 'setTimeout(function() {' | |
+ ' console.log("title:" + document.title);' | |
+ '}, 300);' | |
); | |
} else { | |
res.writeHead(200, { 'Content-Type': 'text/html' | |
, 'Transfer-Encoding': 'chunked' | |
}); | |
res.write('<html><head><script src="script.js"></script>'); | |
setTimeout(res.end.bind(res) | |
, 200 | |
, '<title>stuff</title></head><body><h1>Yup</h1></body></html>' | |
); | |
} | |
}).listen(9615); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment