http-parser: Error on EOF errors
authorRyan Dahl <ry@tinyclouds.org>
Sat, 5 Feb 2011 00:06:05 +0000 (16:06 -0800)
committerRyan Dahl <ry@tinyclouds.org>
Sat, 5 Feb 2011 02:07:00 +0000 (18:07 -0800)
src/node_http_parser.cc

index 7390a71127c2a4b3a8ee2133aea1959f621c807b..62dea03fd569aba9a12c3c9c6c8c9293390e0cf9 100644 (file)
@@ -308,10 +308,17 @@ class Parser : public ObjectWrap {
     assert(!current_buffer);
     parser->got_exception_ = false;
 
-    http_parser_execute(&(parser->parser_), &settings, NULL, 0);
+    int rv = http_parser_execute(&(parser->parser_), &settings, NULL, 0);
 
     if (parser->got_exception_) return Local<Value>();
 
+    if (rv != 0) {
+      Local<Value> e = Exception::Error(String::NewSymbol("Parse Error"));
+      Local<Object> obj = e->ToObject();
+      obj->Set(String::NewSymbol("bytesParsed"), Integer::New(0));
+      return scope.Close(e);
+    }
+
     return Undefined();
   }