Skip to content

Commit 184f09d

Browse files
committed
http: cork/uncork before flushing pipelined res
Make sure that the pipelined response data will be written as less TCP packets as possible. PR-URL: #3172 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
1 parent d1f2404 commit 184f09d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/_http_outgoing.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,12 @@ OutgoingMessage.prototype._writeRaw = function(data, encoding, callback) {
161161
var output = this.output;
162162
var outputEncodings = this.outputEncodings;
163163
var outputCallbacks = this.outputCallbacks;
164+
connection.cork();
164165
for (var i = 0; i < outputLength; i++) {
165166
connection.write(output[i], outputEncodings[i],
166167
outputCallbacks[i]);
167168
}
169+
connection.uncork();
168170

169171
this.output = [];
170172
this.outputEncodings = [];
@@ -651,10 +653,12 @@ OutgoingMessage.prototype._flush = function() {
651653
var output = this.output;
652654
var outputEncodings = this.outputEncodings;
653655
var outputCallbacks = this.outputCallbacks;
656+
socket.cork();
654657
for (var i = 0; i < outputLength; i++) {
655658
ret = socket.write(output[i], outputEncodings[i],
656659
outputCallbacks[i]);
657660
}
661+
socket.uncork();
658662

659663
this.output = [];
660664
this.outputEncodings = [];

0 commit comments

Comments
 (0)