diff options
Diffstat (limited to 'lib/_http_outgoing.js')
-rw-r--r-- | lib/_http_outgoing.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 397b430c2f..fd4681f39f 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -115,7 +115,7 @@ OutgoingMessage.prototype._send = function(data, encoding) { // the same packet. Future versions of Node are going to take care of // this at a lower level and in a more general way. if (!this._headerSent) { - if (typeof data === 'string') { + if (IS_STRING(data)) { data = this._header + data; } else { this.output.unshift(this._header); @@ -166,7 +166,7 @@ OutgoingMessage.prototype._buffer = function(data, encoding) { var length = this.output.length; - if (length === 0 || typeof data != 'string') { + if (length === 0 || !IS_STRING(data)) { this.output.push(data); this.outputEncodings.push(encoding); return false; @@ -205,7 +205,7 @@ OutgoingMessage.prototype._storeHeader = function(firstLine, headers) { if (headers) { var keys = Object.keys(headers); - var isArray = (Array.isArray(headers)); + var isArray = IS_ARRAY(headers); var field, value; for (var i = 0, l = keys.length; i < l; i++) { @@ -218,7 +218,7 @@ OutgoingMessage.prototype._storeHeader = function(firstLine, headers) { value = headers[key]; } - if (Array.isArray(value)) { + if (IS_ARRAY(value)) { for (var j = 0; j < value.length; j++) { storeHeader(this, state, field, value[j]); } @@ -401,7 +401,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding) { return true; } - if (typeof chunk !== 'string' && !Buffer.isBuffer(chunk)) { + if (!IS_STRING(chunk) && !IS_BUFFER(chunk)) { throw new TypeError('first argument must be a string or Buffer'); } @@ -412,7 +412,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding) { var len, ret; if (this.chunkedEncoding) { - if (typeof(chunk) === 'string' && + if (IS_STRING(chunk) && encoding !== 'hex' && encoding !== 'base64' && encoding !== 'binary') { @@ -444,7 +444,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding) { OutgoingMessage.prototype.addTrailers = function(headers) { this._trailer = ''; var keys = Object.keys(headers); - var isArray = (Array.isArray(headers)); + var isArray = IS_ARRAY(headers); var field, value; for (var i = 0, l = keys.length; i < l; i++) { var key = keys[i]; @@ -466,7 +466,7 @@ var crlf_buf = new Buffer('\r\n'); OutgoingMessage.prototype.end = function(data, encoding) { - if (data && typeof data !== 'string' && !Buffer.isBuffer(data)) { + if (data && !IS_STRING(data) && !IS_BUFFER(data)) { throw new TypeError('first argument must be a string or Buffer'); } |