Skip to content

Instantly share code, notes, and snippets.

@eborden
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eborden/e69054ec4c463bfd2f9a to your computer and use it in GitHub Desktop.
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"
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