about summary refs log tree commit homepage
path: root/ext
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-09-14 23:13:56 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-14 23:19:17 -0700
commita03116fc5b290e5af9a17e7a01558cd1d01ecde4 (patch)
tree45a381cb024945494d6ce5b225ed04bda847ac1b /ext
parent06efebe6139acbe819ef5c4e8b0e832c113fb9ef (diff)
downloadunicorn-a03116fc5b290e5af9a17e7a01558cd1d01ecde4.tar.gz
Rubinius supports these functions as of
  039091066244cfcf483310b86b5c4989aaa6302b

This allows the test_http_parser_ng.rb test to run under
Rubinius db612aa62cad9e5cc41a4a4be645642362029d20
Diffstat (limited to 'ext')
-rw-r--r--ext/unicorn_http/ext_help.h6
-rw-r--r--ext/unicorn_http/unicorn_http.rl10
2 files changed, 14 insertions, 2 deletions
diff --git a/ext/unicorn_http/ext_help.h b/ext/unicorn_http/ext_help.h
index 8df2d80..d1b71d6 100644
--- a/ext/unicorn_http/ext_help.h
+++ b/ext/unicorn_http/ext_help.h
@@ -8,12 +8,18 @@
 #define RSTRING_LEN(s) (RSTRING(s)->len)
 #endif
 
+#ifndef RUBINIUS
+#  define rb_str_update(x) do {} while (0)
+#  define rb_str_flush(x) do {} while (0)
+#endif /* !RUBINIUS */
+
 #ifndef HAVE_RB_STR_SET_LEN
 /* this is taken from Ruby 1.8.7, 1.8.6 may not have it */
 static void rb_18_str_set_len(VALUE str, long len)
 {
   RSTRING(str)->len = len;
   RSTRING(str)->ptr[len] = '\0';
+  rb_str_flush(str);
 }
 #  define rb_str_set_len(str,len) rb_18_str_set_len(str,len)
 #endif
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl
index ee23a52..26cac0f 100644
--- a/ext/unicorn_http/unicorn_http.rl
+++ b/ext/unicorn_http/unicorn_http.rl
@@ -527,6 +527,8 @@ static VALUE HttpParser_headers(VALUE self, VALUE req, VALUE data)
 {
   struct http_parser *hp = data_get(self);
 
+  rb_str_update(data);
+
   http_parser_execute(hp, req, RSTRING_PTR(data), RSTRING_LEN(data));
   VALIDATE_MAX_LENGTH(hp->start.offset, HEADER);
 
@@ -616,8 +618,12 @@ static VALUE HttpParser_has_headers(VALUE self)
 static VALUE HttpParser_filter_body(VALUE self, VALUE buf, VALUE data)
 {
   struct http_parser *hp = data_get(self);
-  char *dptr = RSTRING_PTR(data);
-  long dlen = RSTRING_LEN(data);
+  char *dptr;
+  long dlen;
+
+  rb_str_update(data);
+  dptr = RSTRING_PTR(data);
+  dlen = RSTRING_LEN(data);
 
   StringValue(buf);
   rb_str_resize(buf, dlen); /* we can never copy more than dlen bytes */