Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A dumb example of delaying some content to see chunked encoding (with extra data for WebKit)
var http = require('http')
http.createServer(function (request, response) {
response.writeHead(200, {
'Content-Type': 'text/html',
'Transfer-Encoding': 'chunked'
response.write("<html><head><title>delay</title></head><body><div id=before>before</div>\n" + Array(160).join("&nbsp;") + "\n")
setTimeout(function() {
response.end("<div id=after>after</div></body></html>")
}, 6000)
console.log('Server running at http://localhost:3002/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment