From 27fcae738a7f6b3452a15c1bfcaee280b74ac71c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Sun, 22 Nov 2009 13:47:20 +0100 Subject: [PATCH] Reduce multipart memory footprint Multipart parts kept the first chunk of data after their headers in memory, even so that was no longer needed. --- lib/multipart.js | 1 + test/mjsunit/test-multipart.js | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/multipart.js b/lib/multipart.js index 9b2d7b5c165..c700788cdad 100644 --- a/lib/multipart.js +++ b/lib/multipart.js @@ -159,6 +159,7 @@ Part.prototype.write = function(chunk) { this.buffer = this.buffer.substr(2); this.bytesReceived = this.bytesReceived + this.buffer.length; this.emit('body', this.buffer); + this.buffer = ''; return; } else if (offset > 0) { var header = this.buffer.substr(0, offset).split(/: ?/); diff --git a/test/mjsunit/test-multipart.js b/test/mjsunit/test-multipart.js index a44ea6d55c4..aca5efb2fb9 100644 --- a/test/mjsunit/test-multipart.js +++ b/test/mjsunit/test-multipart.js @@ -28,6 +28,7 @@ var server = http.createServer(function(req, res) { parts[name] += chunk; }); part.addListener('complete', function(chunk) { + assertEquals(0, part.buffer.length); if (parts_reveived == 1) { assertEquals('yes', parts[name]); } else if (parts_reveived == 2) {