diff --git a/src/beast/beast/asio/streambuf.h b/src/beast/beast/asio/streambuf.h index 5d1c951b9..5e8654986 100644 --- a/src/beast/beast/asio/streambuf.h +++ b/src/beast/beast/asio/streambuf.h @@ -27,6 +27,7 @@ #include #include #include // +#include #include namespace beast { @@ -654,6 +655,20 @@ basic_streambuf::debug_check() const using streambuf = basic_streambuf>; +/** Convert the entire basic_streambuf to a string. + @note It is more efficient to deal directly in the streambuf instead. +*/ +template +std::string +to_string (basic_streambuf const& buf) +{ + std::string s; + s.resize(buf.size()); + boost::asio::buffer_copy(boost::asio::buffer(s), + buf.data()); + return s; +} + } }