7a8
> #include <nxt_unit.h>
13d13
< static size_t nxt_ruby_stream_io_read_line(nxt_app_rmsg_t *rmsg, VALUE str);
88,89c88,93
< VALUE buf;
< nxt_ruby_run_ctx_t *run_ctx;
---
> VALUE buf;
> char *p;
> size_t size, b_size;
> nxt_unit_buf_t *b;
> nxt_ruby_run_ctx_t *run_ctx;
> nxt_unit_request_info_t *req;
93,95c97
< if (run_ctx->body_preread_size == 0) {
< return Qnil;
< }
---
> req = run_ctx->req;
97,99c99
< buf = rb_str_buf_new(1);
<
< if (buf == Qnil) {
---
> if (req->content_length == 0) {
103,104c103
< run_ctx->body_preread_size -= nxt_ruby_stream_io_read_line(run_ctx->rmsg,
< buf);
---
> size = 0;
106,107c105,107
< return buf;
< }
---
> for (b = req->content_buf; b; b = nxt_unit_buf_next(b)) {
> b_size = b->end - b->free;
> p = memchr(b->free, '\n', b_size);
109,123d108
<
< static size_t
< nxt_ruby_stream_io_read_line(nxt_app_rmsg_t *rmsg, VALUE str)
< {
< size_t len, size;
< u_char *p;
< nxt_buf_t *buf;
<
< len = 0;
<
< for (buf = rmsg->buf; buf != NULL; buf = buf->next) {
<
< size = nxt_buf_mem_used_size(&buf->mem);
< p = memchr(buf->mem.pos, '\n', size);
<
126,132c111
< size = p - buf->mem.pos;
<
< rb_str_cat(str, (const char *) buf->mem.pos, size);
<
< len += size;
< buf->mem.pos = p;
<
---
> size += p - b->free;
136c115,116
< rb_str_cat(str, (const char *) buf->mem.pos, size);
---
> size += b_size;
> }
138,139c118,121
< len += size;
< buf->mem.pos = buf->mem.free;
---
> buf = rb_str_buf_new(size);
>
> if (buf == Qnil) {
> return Qnil;
142c124
< rmsg->buf = buf;
---
> size = nxt_unit_request_read(req, RSTRING_PTR(buf), size);
144c126,128
< return len;
---
> rb_str_set_len(buf, size);
>
> return buf;
176d159
< size_t len;
181c164
< copy_size = run_ctx->body_preread_size;
---
> copy_size = run_ctx->req->content_length;
205,206c188,189
< len = nxt_app_msg_read_raw(run_ctx->task, run_ctx->rmsg,
< RSTRING_PTR(buf), (size_t) copy_size);
---
> copy_size = nxt_unit_request_read(run_ctx->req, RSTRING_PTR(buf),
> copy_size);
214c197
< rb_str_set_len(buf, (long) len);
---
> rb_str_set_len(buf, copy_size);
216,217d198
< run_ctx->body_preread_size -= len;
<
279,280c260
< nxt_log_error(NXT_LOG_ERR, run_ctx->task->log, "Ruby: %s",
< RSTRING_PTR(val));
---
> nxt_unit_req_error(run_ctx->req, "Ruby: %s", RSTRING_PTR(val));