Skip to content
Browse files

[tls] chunkify writes

  • Loading branch information...
1 parent 425b57b commit a1c7eb1faa5a82614817d8107272c228afc56fea @indutny committed Apr 14, 2011
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/tls.js
View
14 lib/tls.js
@@ -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;
};

0 comments on commit a1c7eb1

Please sign in to comment.
Something went wrong with that request. Please try again.