about summary refs log tree commit homepage
path: root/ext
diff options
context:
space:
mode:
authorzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-01-30 06:25:20 +0000
committerzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-01-30 06:25:20 +0000
commit6bcf6e6d949ee380d95417bf2cb0e4902768008c (patch)
treec79ea57c5cd122e9e911078031f6611d6069c3b5 /ext
parent6d2285964165ae6a33753b59e8f1f6200229c510 (diff)
downloadunicorn-6bcf6e6d949ee380d95417bf2cb0e4902768008c.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@15 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'ext')
-rw-r--r--ext/http11/http11.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ext/http11/http11.c b/ext/http11/http11.c
index 3755d65..cbfb55e 100644
--- a/ext/http11/http11.c
+++ b/ext/http11/http11.c
@@ -152,6 +152,10 @@ VALUE HttpParser_finish(VALUE self)
  * returning an Integer to indicate how much of the data has been read.  No matter
  * what the return value, you should call HttpParser#finished? and HttpParser#error?
  * to figure out if it's done parsing or there was an error.
+ *
+ * This function now throws an exception when there is a parsing error.  This makes
+ * the logic for working with the parser much easier.  You can still test for an
+ * error, but now you need to wrap the parser with an exception handling block.
  */
 VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data)
 {
@@ -160,8 +164,12 @@ VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data)
 
   http->data = (void *)req_hash;
   http_parser_execute(http, RSTRING(data)->ptr, RSTRING(data)->len);
-  
-  return INT2FIX(http_parser_nread(http));
+
+  if(http_parser_has_error(http)) {
+    rb_raise(rb_eStandardError, "HTTP Parsing failure");
+  } else {
+    return INT2FIX(http_parser_nread(http));
+  }
 }