http: add callback is function check
We were checking that the callback existed, but not checking that it was a function. In `setTimeout`, if callback is truthy but not a function, throw a TypeError Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: https://github.com/nodejs/node/pull/3090
This commit is contained in:
parent
05d424c029
commit
0094a8dad7
@ -89,8 +89,12 @@ exports.OutgoingMessage = OutgoingMessage;
|
|||||||
|
|
||||||
|
|
||||||
OutgoingMessage.prototype.setTimeout = function(msecs, callback) {
|
OutgoingMessage.prototype.setTimeout = function(msecs, callback) {
|
||||||
if (callback)
|
|
||||||
|
if (callback) {
|
||||||
|
if (typeof callback !== 'function')
|
||||||
|
throw new TypeError('callback must be a function');
|
||||||
this.on('timeout', callback);
|
this.on('timeout', callback);
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.socket) {
|
if (!this.socket) {
|
||||||
this.once('socket', function(socket) {
|
this.once('socket', function(socket) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user