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:
Родитель
05d424c029
Коммит
0094a8dad7
|
@ -89,8 +89,12 @@ exports.OutgoingMessage = OutgoingMessage;
|
|||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (!this.socket) {
|
||||
this.once('socket', function(socket) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче