Skip to content

Instantly share code, notes, and snippets.

@dalmaer
Created June 11, 2012 04:59
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 dalmaer/2908574 to your computer and use it in GitHub Desktop.
Save dalmaer/2908574 to your computer and use it in GitHub Desktop.
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)
}).listen(3002)
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