10 #ifndef BOOST_BEAST_HTTP_STRING_BODY_HPP 11 #define BOOST_BEAST_HTTP_STRING_BODY_HPP 17 #include <boost/asio/buffer.hpp> 18 #include <boost/optional.hpp> 38 class Traits = std::char_traits<CharT>,
39 class Allocator = std::allocator<CharT>>
44 std::is_integral<CharT>::value &&
46 "CharT requirements not met");
55 std::basic_string<CharT, Traits, Allocator>;
74 #if BOOST_BEAST_DOXYGEN 75 using reader = implementation_defined;
83 boost::asio::const_buffers_1;
85 template<
bool isRequest,
class Fields>
96 ec.assign(0, ec.category());
99 boost::optional<std::pair<const_buffers_type, bool>>
102 ec.assign(0, ec.category());
104 body_.data(), body_.size()},
false}};
113 #if BOOST_BEAST_DOXYGEN 114 using writer = implementation_defined;
121 template<
bool isRequest,
class Fields>
136 std::numeric_limits<std::size_t>::max)())
144 static_cast<std::size_t>(*length));
146 catch(std::exception
const&)
152 ec.assign(0, ec.category());
155 template<
class ConstBufferSequence>
160 using boost::asio::buffer_size;
161 using boost::asio::buffer_copy;
162 auto const extra = buffer_size(buffers);
163 auto const size = body_.size();
166 body_.resize(
size + extra);
168 catch(std::exception
const&)
173 ec.assign(0, ec.category());
174 CharT* dest = &body_[
size];
175 for(boost::asio::const_buffer b : buffers)
177 using boost::asio::buffer_cast;
178 auto const len = boost::asio::buffer_size(b);
180 dest, buffer_cast<CharT const*>(b), len);
189 ec.assign(0, ec.category());
BufferSequence< boost::asio::const_buffer > ConstBufferSequence
Definition: type_traits.hpp:280
reader(message< isRequest, basic_string_body, Fields > const &msg)
Definition: string_body.hpp:87
Definition: async_result.hpp:20
Definition: type_traits.hpp:25
detail::buffers_helper< ConstBufferSequence > buffers(ConstBufferSequence const &b)
Definition: ostream.hpp:50
Definition: string_body.hpp:116
writer(message< isRequest, basic_string_body, Fields > &m)
Definition: string_body.hpp:123
std::size_t put(ConstBufferSequence const &buffers, error_code &ec)
Definition: string_body.hpp:157
Definition: beast_common.hpp:6
boost::system::error_code error_code
The type of error code used by the library.
Definition: error.hpp:21
std::basic_string< CharT, Traits, Allocator > value_type
Definition: string_body.hpp:55
Definition: string_body.hpp:77
void finish(error_code &ec)
Definition: string_body.hpp:187
Definition: string_body.hpp:40
boost::asio::const_buffers_1 const_buffers_type
Definition: string_body.hpp:83
void init(error_code &ec)
Definition: string_body.hpp:94
static std::uint64_t size(value_type const &body)
Definition: string_body.hpp:65
void init(boost::optional< std::uint64_t > const &length, error_code &ec)
Definition: string_body.hpp:130