about summary refs log tree commit homepage
path: root/ext
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-06-10 16:00:08 -0700
committerEric Wong <normalperson@yhbt.net>2009-06-10 16:00:08 -0700
commit4651cd8b7c10d18bc745b84ebc7a55aad07d6077 (patch)
tree01ae0123891d16aa51ab18ff7c65d2dd1f3e733f /ext
parentb0013b043a15d77d810d5965157766c1af364db2 (diff)
downloadunicorn-4651cd8b7c10d18bc745b84ebc7a55aad07d6077.tar.gz
No point in making syscalls to deal with empty bodies.
Reinstate usage of the NULL_IO object which allows us
to avoid allocating new objects.
Diffstat (limited to 'ext')
-rw-r--r--ext/unicorn/http11/http11.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/unicorn/http11/http11.c b/ext/unicorn/http11/http11.c
index cd7a8f7..f640a08 100644
--- a/ext/unicorn/http11/http11.c
+++ b/ext/unicorn/http11/http11.c
@@ -324,10 +324,17 @@ static void header_done(void *data, const char *at, size_t length)
   }
   rb_hash_aset(req, global_server_name, server_name);
   rb_hash_aset(req, global_server_port, server_port);
+  rb_hash_aset(req, global_server_protocol, global_server_protocol_value);
 
   /* grab the initial body and stuff it into the hash */
-  rb_hash_aset(req, sym_http_body, rb_str_new(at, length));
-  rb_hash_aset(req, global_server_protocol, global_server_protocol_value);
+  temp = rb_hash_aref(req, global_request_method);
+  if (temp != Qnil) {
+    long len = RSTRING_LEN(temp);
+    char *ptr = RSTRING_PTR(temp);
+
+    if (memcmp(ptr, "HEAD", len) && memcmp(ptr, "GET", len))
+      rb_hash_aset(req, sym_http_body, rb_str_new(at, length));
+  }
 }
 
 static void HttpParser_free(void *data) {