Skip to content

Commit 2ddbbfd

Browse files
indutnyjasnell
authored andcommitted
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 <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent 660f759 commit 2ddbbfd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/_http_outgoing.js

+4
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,12 @@ OutgoingMessage.prototype._writeRaw = function(data, encoding, callback) {
157157
var output = this.output;
158158
var outputEncodings = this.outputEncodings;
159159
var outputCallbacks = this.outputCallbacks;
160+
connection.cork();
160161
for (var i = 0; i < outputLength; i++) {
161162
connection.write(output[i], outputEncodings[i],
162163
outputCallbacks[i]);
163164
}
165+
connection.uncork();
164166

165167
this.output = [];
166168
this.outputEncodings = [];
@@ -637,10 +639,12 @@ OutgoingMessage.prototype._flush = function() {
637639
var output = this.output;
638640
var outputEncodings = this.outputEncodings;
639641
var outputCallbacks = this.outputCallbacks;
642+
socket.cork();
640643
for (var i = 0; i < outputLength; i++) {
641644
ret = socket.write(output[i], outputEncodings[i],
642645
outputCallbacks[i]);
643646
}
647+
socket.uncork();
644648

645649
this.output = [];
646650
this.outputEncodings = [];

0 commit comments

Comments
 (0)