From: isaacs Date: Wed, 5 May 2010 01:28:49 +0000 (-0700) Subject: Emit a better error message when something strange is sent to OutgoingMessage#write X-Git-Tag: v0.1.94~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3892628657ca3e56d16473e65da35c77a74382c7;p=platform%2Fupstream%2Fnodejs.git Emit a better error message when something strange is sent to OutgoingMessage#write --- diff --git a/lib/http.js b/lib/http.js index 3cfe75b..3737b9c 100644 --- a/lib/http.js +++ b/lib/http.js @@ -10,6 +10,7 @@ function debug (x) { var sys = require('sys'); var net = require('net'); var events = require('events'); +var Buffer = require('buffer').Buffer; var FreeList = require('freelist').FreeList; var HTTPParser = process.binding('http_parser').HTTPParser; @@ -345,6 +346,12 @@ OutgoingMessage.prototype.write = function (chunk, encoding) { throw new Error("This type of response MUST NOT have a body."); } + if (typeof chunk !== "string" + && !(chunk instanceof Buffer) + && !Array.isArray(chunk)) { + throw new TypeError("first argument must be a string, Array, or Buffer"); + } + encoding = encoding || "ascii"; if (this.chunkedEncoding) { if (typeof chunk == 'string') {