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:47 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-06 14:31:22 -0700
commitbace4364e8a7d0ac261e407732b9354d2f017045 (patch)
tree43b77c9e7a18ba3dbba6c16f0a4af43c44b0ab2a /ext
parent141eb25bf0a34d6994de71f71488e4d97727950b (diff)
downloadunicorn-bace4364e8a7d0ac261e407732b9354d2f017045.tar.gz
Just pass the http_parser struct pointer when checking for
invalid headers in the trailer.  The compiler should be smart
enough to inline and not relookup the flags.  This avoids having
to worry about the flags being signed or not (they should never
be) and also makes it easier to maintain if we move away from
using bitfields.
Diffstat (limited to 'ext')
-rw-r--r--ext/unicorn_http/unicorn_http.rl10
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl
index 7a0c02d..063b326 100644
--- a/ext/unicorn_http/unicorn_http.rl
+++ b/ext/unicorn_http/unicorn_http.rl
@@ -88,9 +88,9 @@ http_version(struct http_parser *hp, VALUE req, const char *ptr, size_t len)
   rb_hash_aset(req, g_http_version, v);
 }
 
-static void invalid_if_trailer(int flags)
+static inline void hp_invalid_if_trailer(struct http_parser *hp)
 {
-  if (flags & UH_FL_INTRAILER)
+  if (hp->flags & UH_FL_INTRAILER)
     rb_raise(eHttpParserError, "invalid Trailer");
 }
 
@@ -143,14 +143,14 @@ static void write_value(VALUE req, struct http_parser *hp,
     if (hp->len.content < 0)
       rb_raise(eHttpParserError, "invalid Content-Length");
     hp->flags |= UH_FL_HASBODY;
-    invalid_if_trailer(hp->flags);
+    hp_invalid_if_trailer(hp);
   } else if (f == g_http_transfer_encoding) {
     if (STR_CSTR_CASE_EQ(v, "chunked"))
       hp->flags |= UH_FL_CHUNKED | UH_FL_HASBODY;
-    invalid_if_trailer(hp->flags);
+    hp_invalid_if_trailer(hp);
   } else if (f == g_http_trailer) {
     hp->flags |= UH_FL_HASTRAILER;
-    invalid_if_trailer(hp->flags);
+    hp_invalid_if_trailer(hp);
   }
 
   e = rb_hash_aref(req, f);