http: Prefer 'binary' over 'ascii'
It's faster, because it doesn't have to check that each char is in the ASCII plane.
This commit is contained in:
parent
df23ce138f
commit
1f9f863494
@ -122,7 +122,7 @@ OutgoingMessage.prototype._send = function(data, encoding, callback) {
|
|||||||
data = this._header + data;
|
data = this._header + data;
|
||||||
} else {
|
} else {
|
||||||
this.output.unshift(this._header);
|
this.output.unshift(this._header);
|
||||||
this.outputEncodings.unshift('ascii');
|
this.outputEncodings.unshift('binary');
|
||||||
this.outputCallbacks.unshift(null);
|
this.outputCallbacks.unshift(null);
|
||||||
}
|
}
|
||||||
this._headerSent = true;
|
this._headerSent = true;
|
||||||
@ -421,7 +421,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding, callback) {
|
|||||||
|
|
||||||
if (this.connection)
|
if (this.connection)
|
||||||
this.connection.cork();
|
this.connection.cork();
|
||||||
this._send(len.toString(16), 'ascii', null);
|
this._send(len.toString(16), 'binary', null);
|
||||||
this._send(crlf_buf, null, null);
|
this._send(crlf_buf, null, null);
|
||||||
this._send(chunk, encoding, null);
|
this._send(chunk, encoding, null);
|
||||||
ret = this._send(crlf_buf, null, callback);
|
ret = this._send(crlf_buf, null, callback);
|
||||||
@ -507,10 +507,10 @@ OutgoingMessage.prototype.end = function(data, encoding, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.chunkedEncoding) {
|
if (this.chunkedEncoding) {
|
||||||
ret = this._send('0\r\n' + this._trailer + '\r\n', 'ascii', finish);
|
ret = this._send('0\r\n' + this._trailer + '\r\n', 'binary', finish);
|
||||||
} else {
|
} else {
|
||||||
// Force a flush, HACK.
|
// Force a flush, HACK.
|
||||||
ret = this._send('', 'ascii', finish);
|
ret = this._send('', 'binary', finish);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.connection && data)
|
if (this.connection && data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user