Skip to content

Commit

Permalink
[tls] chunkify writes
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Apr 13, 2011
1 parent 425b57b commit a1c7eb1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,19 @@ CleartextStream.prototype._pendingBytes = function() {

CleartextStream.prototype._puller = function(b) {
debug('clearIn ' + b.length + ' bytes');
return this.pair._ssl.clearIn(b, 0, b.length);

var total = b.length,
chunkSize = Math.max(1400, Math.round(total / 1000));

var result = 0;
for (var i = 0, len = b.length; i < len; i += chunkSize) {
var chunk = b.slice(i, i + chunkSize),
clearResult = this.pair._ssl.clearIn(chunk, 0, chunkSize);

if (clearResult < 0) return clearResult;
result += clearResult;
}
return clearResult;
};


Expand Down

0 comments on commit a1c7eb1

Please sign in to comment.