Permalink
Browse files

Merge remote-tracking branch 'origin/v0.8'

  • Loading branch information...
2 parents dcaebec + 5a19c07 commit 79ae8b7ae2fb67f39375f46e0ad7552aa9fb82ea @bnoordhuis bnoordhuis committed Dec 20, 2012
Showing with 661 additions and 19 deletions.
  1. +4 −5 benchmark/http_simple.js
  2. +4 −5 benchmark/http_simple_auto.js
  3. +579 −0 doc/blog/feature/streams2.md
  4. +2 −0 doc/community/index.html
  5. +71 −8 lib/http.js
  6. +1 −1 tools/install.py
View
@@ -96,13 +96,12 @@ var server = http.createServer(function (req, res) {
'Transfer-Encoding': 'chunked' });
// send body in chunks
var len = body.length;
- var step = ~~(len / n_chunks) || len;
+ var step = Math.floor(len / n_chunks) || 1;
- for (var i = 0; i < len; i += step) {
- res.write(body.slice(i, i + step));
+ for (var i = 0, n = (n_chunks - 1); i < n; ++i) {
+ res.write(body.slice(i * step, i * step + step));
}
-
- res.end();
+ res.end(body.slice((n_chunks - 1) * step));
} else {
var content_length = body.length.toString();
@@ -77,13 +77,12 @@ var server = http.createServer(function (req, res) {
"Transfer-Encoding": "chunked" });
// send body in chunks
var len = body.length;
- var step = ~~(len / n_chunks) || len;
+ var step = Math.floor(len / n_chunks) || 1;
- for (var i = 0; i < len; i += step) {
- res.write(body.slice(i, i + step));
+ for (var i = 0, n = (n_chunks - 1); i < n; ++i) {
+ res.write(body.slice(i * step, i * step + step));
}
-
- res.end();
+ res.end(body.slice((n_chunks - 1) * step));
} else {
var content_length = body.length.toString();
Oops, something went wrong.

0 comments on commit 79ae8b7

Please sign in to comment.