summaryrefslogtreecommitdiff
path: root/test/simple
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2014-09-29 12:32:42 -0700
committerTrevor Norris <trev.norris@gmail.com>2014-09-29 12:32:42 -0700
commit979d0ca874df0383311ca06f154f6965074196ee (patch)
treef0991b807427113d825c4149a065496b59229e2e /test/simple
parentde312cfd7c21c551d497af49aa981e07ed2f5ba3 (diff)
downloadnode-new-979d0ca874df0383311ca06f154f6965074196ee.tar.gz
http: cleanup setHeader()
Several fields on OutgoingMessage were set after instantiation. These have been included in the constructor to prevent mutation of the object map after instantiation. "name" is now explicitly checked to be a string. Where before if a non-string was passed the following cryptic error was thrown: _http_outgoing.js:334 var key = name.toLowerCase(); ^ TypeError: undefined is not a function Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'test/simple')
-rw-r--r--test/simple/test-http-write-head.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/simple/test-http-write-head.js b/test/simple/test-http-write-head.js
index 2de59fe2ed..88923ef27a 100644
--- a/test/simple/test-http-write-head.js
+++ b/test/simple/test-http-write-head.js
@@ -28,6 +28,17 @@ var http = require('http');
var s = http.createServer(function(req, res) {
res.setHeader('test', '1');
+
+ // toLowerCase() is used on the name argument, so it must be a string.
+ var threw = false;
+ try {
+ res.setHeader(0xf00, 'bar');
+ } catch (e) {
+ assert.ok(e instanceof TypeError);
+ threw = true;
+ }
+ assert.ok(threw, 'Non-string names should throw');
+
res.writeHead(200, { Test: '2' });
res.end();
});