about summary refs log tree commit homepage
path: root/ext
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-09-06 14:29:52 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-06 14:31:31 -0700
commit21e1fd3f5c53ea3833d54c18e1a4b92e710e1189 (patch)
treeea5b46896bddc73346817e285daaeed48c96b681 /ext
parent56c31ac07e737eb0566c21f08612c04371eb9e68 (diff)
downloadunicorn-21e1fd3f5c53ea3833d54c18e1a4b92e710e1189.tar.gz
There's no need to use a goto here to avoid one level of
nesting.
Diffstat (limited to 'ext')
-rw-r--r--ext/unicorn_http/unicorn_http.rl32
1 files changed, 15 insertions, 17 deletions
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl
index 99f0ff6..f8649fe 100644
--- a/ext/unicorn_http/unicorn_http.rl
+++ b/ext/unicorn_http/unicorn_http.rl
@@ -619,22 +619,21 @@ static VALUE HttpParser_filter_body(VALUE self, VALUE buf, VALUE data)
   OBJ_TAINT(buf); /* keep weirdo $SAFE users happy */
 
   if (HP_FL_TEST(hp, CHUNKED)) {
-    if (chunked_eof(hp))
-      goto end_of_body;
-
-    hp->s.dest_offset = 0;
-    http_parser_execute(hp, buf, dptr, dlen);
-    if (hp->cs == http_parser_error)
-      rb_raise(eHttpParserError, "Invalid HTTP format, parsing fails.");
-
-    assert(hp->s.dest_offset <= hp->start.offset);
-    advance_str(data, hp->start.offset);
-    rb_str_set_len(buf, hp->s.dest_offset);
-
-    if (RSTRING_LEN(buf) == 0 && chunked_eof(hp)) {
-      assert(hp->len.chunk == 0);
-    } else {
-      data = Qnil;
+    if (!chunked_eof(hp)) {
+      hp->s.dest_offset = 0;
+      http_parser_execute(hp, buf, dptr, dlen);
+      if (hp->cs == http_parser_error)
+        rb_raise(eHttpParserError, "Invalid HTTP format, parsing fails.");
+
+      assert(hp->s.dest_offset <= hp->start.offset);
+      advance_str(data, hp->start.offset);
+      rb_str_set_len(buf, hp->s.dest_offset);
+
+      if (RSTRING_LEN(buf) == 0 && chunked_eof(hp)) {
+        assert(hp->len.chunk == 0);
+      } else {
+        data = Qnil;
+      }
     }
   } else {
     /* no need to enter the Ragel machine for unchunked transfers */
@@ -651,7 +650,6 @@ static VALUE HttpParser_filter_body(VALUE self, VALUE buf, VALUE data)
       data = Qnil;
     }
   }
-end_of_body:
   hp->start.offset = 0; /* for trailer parsing */
   return data;
 }