Boost C++ Libraries

PrevUpHomeNext

Struct multipart_stream_arg

boost::taar::handler::multipart_stream_arg — Argument provider that hands the callable a multipart_reader over a streamed multipart/form-data body.

Synopsis

// In header: <boost/taar/handler/rest_arg.hpp>


struct multipart_stream_arg {

  // public member functions
  explicit multipart_stream_arg(::boost::taar::handler::description = {});
  std::string name() const;
  std::string const & description() const;
  taar::result< multipart_reader > 
  operator()(streaming_request const &, matcher::context const &) const;

  // public data members
  std::string description_;
};

Description

The callable parameter is multipart_reader (by value). Parts are consumed one at a time with bounded memory; the session's body limit does not apply. Requests without a multipart boundary are reported as error::invalid_content_type.

rest([](taar::multipart_reader form) -> taar::awaitable<std::string>
{
    std::uint64_t bytes = 0;
    while (auto part = co_await form.next_part())
        while (!form.part_done()) bytes += (co_await form.read_some()).size();
    co_return std::to_string(bytes);
}, multipart_stream_arg {});

multipart_stream_arg public member functions

  1. explicit multipart_stream_arg(::boost::taar::handler::description d = {});
  2. std::string name() const;
  3. std::string const & description() const;
  4. taar::result< multipart_reader > 
    operator()(streaming_request const & request, matcher::context const &) const;

PrevUpHomeNext