diff options
-rw-r--r-- | ext/unicorn_http/unicorn_http.rl | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl index b6319df..106cc6b 100644 --- a/ext/unicorn_http/unicorn_http.rl +++ b/ext/unicorn_http/unicorn_http.rl @@ -908,6 +908,13 @@ static VALUE HttpParser_filter_body(VALUE self, VALUE dst, VALUE src) if (hp->len.content > 0) { long nr = MIN(srclen, hp->len.content); + /* + * using rb_str_replace() to avoid memcpy() doesn't help in + * most cases because a GC-aware programmer will pass an explicit + * buffer to env["rack.input"].read and reuse the buffer in a loop. + * This causes copy-on-write behavior to be triggered anyways + * when the +src+ buffer is modified (when reading off the socket). + */ hp->buf = src; memcpy(RSTRING_PTR(dst), srcptr, nr); hp->len.content -= nr; |