Browse Source

Reduce multipart memory footprint

Multipart parts kept the first chunk of data after their headers in
memory, even so that was no longer needed.
v0.7.4-release
Felix Geisendörfer 16 years ago
committed by Ryan Dahl
parent
commit
27fcae738a
  1. 1
      lib/multipart.js
  2. 1
      test/mjsunit/test-multipart.js

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

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

Loading…
Cancel
Save