Permalink
Browse files

Exemplo de chunked

  • Loading branch information...
0 parents commit c544604eae42084c698bb64c794ad6c9605cdadf @emerleite committed May 17, 2011
Showing with 20 additions and 0 deletions.
  1. +20 −0 chunked.js
@@ -0,0 +1,20 @@
+var http = require('http');
+var server = http.createServer(function (req, res) {
+ res.writeHead(200, {
+ 'Content-Type' : 'text/plain',
+ 'Transfer-Encoding':'chunked'
+ });
+ var contador = 0;
+ var chunkInterval = setInterval(function () {
+ res.write('Resposta Chunked ' + contador + '\n');
+ contador++;
+ }, 100);
+
+ setTimeout(function () {
+ clearInterval(chunkInterval);
+ res.end('Fim\n');
+ }, 10000);
+
+});
+
+server.listen(8000);

0 comments on commit c544604

Please sign in to comment.