From: Ryan Dahl Date: Thu, 30 Sep 2010 18:45:27 +0000 (-0700) Subject: Add test for getting parse error from HTTP client X-Git-Tag: v0.3.0~121 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ee9af669905aeddd6da32712e711aeee9f9d36b3;p=platform%2Fupstream%2Fnodejs.git Add test for getting parse error from HTTP client Made this test in response to this thread: http://groups.google.com/group/nodejs/browse_thread/thread/f82835007a277de2/ But Node appears to be working correctly. --- diff --git a/test/simple/test-http-client-parse-error.js b/test/simple/test-http-client-parse-error.js new file mode 100644 index 0000000..f3a4497 --- /dev/null +++ b/test/simple/test-http-client-parse-error.js @@ -0,0 +1,34 @@ +var common = require("../common"); +var assert = require('assert'); + +var http = require('http'); +var net = require('net'); + +// Create a TCP server +var srv = net.createServer(function(c) { + c.write('bad http - should trigger parse error\r\n'); + + console.log("connection"); + + c.addListener('end', function() { c.end(); }); +}); +srv.listen(common.PORT, '127.0.0.1'); + +var hc = http.createClient(common.PORT, '127.0.0.1'); +hc.request('GET', '/').end(); + +var parseError = false; + +hc.on('error', function (e) { + console.log("got error from client"); + srv.close(); + assert.ok(e.message.indexOf("Parse Error") >= 0); + parseError = true; +}); + + +process.addListener('exit', function() { + assert.ok(parseError); +}); + +