http: use writev on chunked encoding
authorTrevor Norris <trev.norris@gmail.com>
Sat, 7 Dec 2013 01:17:02 +0000 (17:17 -0800)
committerTrevor Norris <trev.norris@gmail.com>
Thu, 9 Jan 2014 23:07:14 +0000 (15:07 -0800)
Now will process all write() that were done on a single tick in a single
writev().

lib/_http_outgoing.js

index b1e2dff..25786ed 100644 (file)
@@ -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);