diff --git a/lib/http.js b/lib/http.js index a42a613c133..e8235425a5c 100644 --- a/lib/http.js +++ b/lib/http.js @@ -825,7 +825,9 @@ ServerResponse.prototype.writeHead = function(statusCode) { } else { // handle object case - for (var k in obj) { + var keys = Object.keys(obj); + for (var i = 0; i < keys.length; i++) { + var k = keys[i]; if (k) headers[k] = obj[k]; } } diff --git a/lib/net_uv.js b/lib/net_uv.js index 29a23519831..ea4aa49b54e 100644 --- a/lib/net_uv.js +++ b/lib/net_uv.js @@ -371,18 +371,13 @@ Socket.prototype.write = function(data, arg1, arg2) { // parse arguments if (arg1) { - switch (typeof arg1) { - case 'string': - encoding = arg1; - cb = arg2; - break; - - case 'function': - cb = arg1; - break; - - default: - throw new Error("bad arg"); + if (typeof arg1 === 'string') { + encoding = arg1; + cb = arg2; + } else if (typeof arg1 === 'function') { + cb = arg1; + } else { + throw new Error("bad arg"); } }