summaryrefslogtreecommitdiff
path: root/boost/beast/websocket/impl/accept.ipp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/beast/websocket/impl/accept.ipp')
-rw-r--r--boost/beast/websocket/impl/accept.ipp52
1 files changed, 15 insertions, 37 deletions
diff --git a/boost/beast/websocket/impl/accept.ipp b/boost/beast/websocket/impl/accept.ipp
index c93e933b18..5a322990a3 100644
--- a/boost/beast/websocket/impl/accept.ipp
+++ b/boost/beast/websocket/impl/accept.ipp
@@ -18,6 +18,7 @@
#include <boost/beast/http/write.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/handler_ptr.hpp>
+#include <boost/beast/core/detail/buffer.hpp>
#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/associated_allocator.hpp>
@@ -244,20 +245,12 @@ run(Buffers const& buffers)
using boost::asio::buffer_size;
auto& d = *d_;
error_code ec;
- boost::optional<typename
- static_buffer_base::mutable_buffers_type> mb;
- auto const len = buffer_size(buffers);
- try
- {
- mb.emplace(d.ws.rd_buf_.prepare(len));
- }
- catch(std::length_error const&)
- {
- ec = error::buffer_overflow;
+ auto const mb = beast::detail::dynamic_buffer_prepare(
+ d.ws.rd_buf_, buffer_size(buffers), ec,
+ error::buffer_overflow);
+ if(ec)
return (*this)(ec);
- }
- d.ws.rd_buf_.commit(
- buffer_copy(*mb, buffers));
+ d.ws.rd_buf_.commit(buffer_copy(*mb, buffers));
(*this)(ec);
}
@@ -432,20 +425,12 @@ accept(
using boost::asio::buffer_copy;
using boost::asio::buffer_size;
reset();
- boost::optional<typename
- static_buffer_base::mutable_buffers_type> mb;
- try
- {
- mb.emplace(rd_buf_.prepare(
- buffer_size(buffers)));
- }
- catch(std::length_error const&)
- {
- ec = error::buffer_overflow;
+ auto const mb = beast::detail::dynamic_buffer_prepare(
+ rd_buf_, buffer_size(buffers), ec,
+ error::buffer_overflow);
+ if(ec)
return;
- }
- rd_buf_.commit(
- buffer_copy(*mb, buffers));
+ rd_buf_.commit(buffer_copy(*mb, buffers));
do_accept(&default_decorate_res, ec);
}
@@ -472,18 +457,11 @@ accept_ex(
using boost::asio::buffer_copy;
using boost::asio::buffer_size;
reset();
- boost::optional<typename
- static_buffer_base::mutable_buffers_type> mb;
- try
- {
- mb.emplace(rd_buf_.prepare(
- buffer_size(buffers)));
- }
- catch(std::length_error const&)
- {
- ec = error::buffer_overflow;
+ auto const mb = beast::detail::dynamic_buffer_prepare(
+ rd_buf_, buffer_size(buffers), ec,
+ error::buffer_overflow);
+ if(ec)
return;
- }
rd_buf_.commit(buffer_copy(*mb, buffers));
do_accept(decorator, ec);
}