From 990fedf9933e088a6d0ca30b2e330b58d20bc488 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 14 Sep 2009 23:55:26 -0700 Subject: http: create a new string buffer on empty values 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... --- ext/unicorn_http/unicorn_http.rl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- cgit v1.2.3-24-ge0c7