summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-06-08 02:46:08 +0000
committerEric Wong <normalperson@yhbt.net>2010-06-08 02:46:08 +0000
commit9a028876d23c7aab1420d81d3c001fbc91354538 (patch)
tree697280aec17903bef9276d15e373f1a26febc7c6
parent7d2295fa774d1c98dfbde2b09d93d58712253d24 (diff)
Since the "Version" header is uncommon and never hits our
optimized case, we don't need to check for it in the common
case.
-rw-r--r--ext/unicorn_http/unicorn_http.rl25
1 files changed, 14 insertions, 11 deletions
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl
index aa23024..f6c632f 100644
--- a/ext/unicorn_http/unicorn_http.rl
+++ b/ext/unicorn_http/unicorn_http.rl
@@ -173,8 +173,20 @@ static void write_value(VALUE req, struct http_parser *hp,
   VALIDATE_MAX_LENGTH(LEN(mark, p), FIELD_VALUE);
   v = LEN(mark, p) == 0 ? rb_str_buf_new(128) : STR_NEW(mark, p);
   if (NIL_P(f)) {
-    VALIDATE_MAX_LENGTH(hp->s.field_len, FIELD_NAME);
-    f = uncommon_field(PTR_TO(start.field), hp->s.field_len);
+    const char *field = PTR_TO(start.field);
+    size_t flen = hp->s.field_len;
+
+    VALIDATE_MAX_LENGTH(flen, FIELD_NAME);
+
+    /*
+     * ignore "Version" headers since they conflict with the HTTP_VERSION
+     * rack env variable.
+     */
+    if (CONST_MEM_EQ("VERSION", field, flen)) {
+      hp->cont = Qnil;
+      return;
+    }
+    f = uncommon_field(field, flen);
   } else if (f == g_http_connection) {
     hp_keepalive_connection(hp, v);
   } else if (f == g_content_length) {
@@ -197,15 +209,6 @@ static void write_value(VALUE req, struct http_parser *hp,
     assert_frozen(f);
   }
 
-  /*
-   * ignore "Version" headers since they conflict with the HTTP_VERSION
-   * rack env variable.
-   */
-  if (rb_str_cmp(f, g_http_version) == 0) {
-    hp->cont = Qnil;
-    return;
-  }
-
   e = rb_hash_aref(req, f);
   if (NIL_P(e)) {
     hp->cont = rb_hash_aset(req, f, v);