This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

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.
  • Loading branch information...
1 parent 45a01af commit 41eca918e5e42167929f199ae07e8b27b3f8322c @ry ry committed Sep 30, 2010
Showing with 34 additions and 0 deletions.
  1. +34 −0 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);
+});
+
+

0 comments on commit 41eca91

Please sign in to comment.