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.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(/: ?/);

View File

@ -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) {