about summary refs log tree commit homepage
path: root/ext
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-09-14 23:55:26 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-14 23:55:26 -0700
commit990fedf9933e088a6d0ca30b2e330b58d20bc488 (patch)
treefa90a0386dc67c944d3128a5470d0740e6e5567e /ext
parenta03116fc5b290e5af9a17e7a01558cd1d01ecde4 (diff)
downloadunicorn-990fedf9933e088a6d0ca30b2e330b58d20bc488.tar.gz
Since empty values on one line can be a heuristic to determine
future lines are continuation lines (and a as a result, a
decently long header), pre-allocate a string buffer just in
case.

This is to workaround what appears to be bug in the Rubinius C
API, but it could be considered (intended) DWIM behavior, too...
Diffstat (limited to 'ext')
-rw-r--r--ext/unicorn_http/unicorn_http.rl2
1 files changed, 1 insertions, 1 deletions
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl
index 26cac0f..39dbd45 100644
--- a/ext/unicorn_http/unicorn_http.rl
+++ b/ext/unicorn_http/unicorn_http.rl
@@ -170,7 +170,7 @@ static void write_value(VALUE req, struct http_parser *hp,
   VALUE e;
 
   VALIDATE_MAX_LENGTH(LEN(mark, p), FIELD_VALUE);
-  v = STR_NEW(mark, p);
+  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);