Reduce multipart memory footprint

Multipart parts kept the first chunk of data after their headers in
memory, even so that was no longer needed.
pull/22966/head
Felix Geisendörfer 2009-11-22 13:47:20 +01:00 committed by Ryan Dahl
parent b6dda61249
commit 27fcae738a
2 changed files with 2 additions and 0 deletions

View File

@ -159,6 +159,7 @@ Part.prototype.write = function(chunk) {
this.buffer = this.buffer.substr(2); this.buffer = this.buffer.substr(2);
this.bytesReceived = this.bytesReceived + this.buffer.length; this.bytesReceived = this.bytesReceived + this.buffer.length;
this.emit('body', this.buffer); this.emit('body', this.buffer);
this.buffer = '';
return; return;
} else if (offset > 0) { } else if (offset > 0) {
var header = this.buffer.substr(0, offset).split(/: ?/); var header = this.buffer.substr(0, offset).split(/: ?/);

View File

@ -28,6 +28,7 @@ var server = http.createServer(function(req, res) {
parts[name] += chunk; parts[name] += chunk;
}); });
part.addListener('complete', function(chunk) { part.addListener('complete', function(chunk) {
assertEquals(0, part.buffer.length);
if (parts_reveived == 1) { if (parts_reveived == 1) {
assertEquals('yes', parts[name]); assertEquals('yes', parts[name]);
} else if (parts_reveived == 2) { } else if (parts_reveived == 2) {