Created
June 11, 2012 04:59
-
-
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)
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
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(" ") + "\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