From 2eddd7411234bf633df6a7bdb9c120ed89853324 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Fri, 6 Dec 2013 17:17:02 -0800 Subject: [PATCH] http: use writev on chunked encoding Now will process all write() that were done on a single tick in a single writev(). --- lib/_http_outgoing.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index b1e2dff50d..25786ed439 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -438,14 +438,18 @@ OutgoingMessage.prototype.write = function(chunk, encoding, callback) { else len = chunk.length; - if (this.connection) + if (this.connection && !this.connection.corked) { this.connection.cork(); + var conn = this.connection; + process.nextTick(function connectionCork() { + if (conn) + conn.uncork(); + }); + } this._send(len.toString(16), 'binary', null); this._send(crlf_buf, null, null); this._send(chunk, encoding, null); ret = this._send(crlf_buf, null, callback); - if (this.connection) - this.connection.uncork(); } } else { ret = this._send(chunk, encoding, callback);