From 21a3edfc60578d28524c46f51209b31a81c191ed Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 7 Sep 2015 23:00:01 +0900 Subject: [PATCH] nghttpx: Use 's' for param of Response::return --- src/shrpx_mruby_module_response.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/shrpx_mruby_module_response.cc b/src/shrpx_mruby_module_response.cc index 0b49e925..00648231 100644 --- a/src/shrpx_mruby_module_response.cc +++ b/src/shrpx_mruby_module_response.cc @@ -180,8 +180,9 @@ mrb_value response_return(mrb_state *mrb, mrb_value self) { mrb_raise(mrb, E_RUNTIME_ERROR, "response has already been committed"); } - mrb_value val; - mrb_get_args(mrb, "|o", &val); + const char *val; + mrb_int vallen; + mrb_get_args(mrb, "|s", &val, &vallen); const uint8_t *body = nullptr; size_t bodylen = 0; @@ -195,9 +196,9 @@ mrb_value response_return(mrb_state *mrb, mrb_value self) { data->response_headers_dirty = false; } - if (downstream->expect_response_body() && !mrb_nil_p(val)) { - body = reinterpret_cast(RSTRING_PTR(val)); - bodylen = RSTRING_LEN(val); + if (downstream->expect_response_body() && vallen > 0) { + body = reinterpret_cast(val); + bodylen = vallen; } auto cl = downstream->get_response_header(http2::HD_CONTENT_LENGTH);