int http_client::read_body(char* buf, size_t size) { if (is_request_) return read_response_body(buf, size); else return read_request_body(buf, size); }
void client::impl::read_response_body(const boost::system::error_code &ec, std::size_t bytes_read, std::shared_ptr<request_context> context, std::shared_ptr<response> res) { context->total_bytes_read_ += bytes_read; if (auto progress = context->options_.progress()) { progress(client_message::transfer_direction::bytes_read, context->total_bytes_read_); } if (bytes_read == 0) { context->response_promise_.set_value(*res); return; } std::istream is(&context->response_buffer_); string_type line; while (!getline_with_newline(is, line).eof()) { res->append_body(line); } context->connection_->async_read(context->response_buffer_, strand_.wrap([=] (const boost::system::error_code &ec, std::size_t bytes_read) { read_response_body(ec, bytes_read, context, res); })); }
int http_client::read_body(string& out, bool clean /* = true */, int* real_size /* = NULL */) { if (is_request_) return read_response_body(out, clean, real_size); else return read_request_body(out, clean, real_size); }