]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/beast/http/basic_dynamic_body.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / beast / http / basic_dynamic_body.hpp
index 7d850d76f33bfd4283866c2ce9cf3fa715f5c44c..f49c50daf8288cd2f7b63451533af810ff197020 100644 (file)
@@ -1,5 +1,5 @@
 //
-// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
+// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -11,7 +11,9 @@
 #define BOOST_BEAST_HTTP_BASIC_DYNAMIC_BODY_HPP
 
 #include <boost/beast/core/detail/config.hpp>
-#include <boost/beast/core/type_traits.hpp>
+#include <boost/beast/core/buffer_traits.hpp>
+#include <boost/beast/core/detail/buffer.hpp>
+#include <boost/beast/core/detail/clamp.hpp>
 #include <boost/beast/http/error.hpp>
 #include <boost/beast/http/message.hpp>
 #include <boost/optional.hpp>
@@ -23,9 +25,9 @@ namespace boost {
 namespace beast {
 namespace http {
 
-/** A @b Body using a @b DynamicBuffer
+/** A <em>Body</em> using a <em>DynamicBuffer</em>
 
-    This body uses a @b DynamicBuffer as a memory-based container
+    This body uses a <em>DynamicBuffer</em> as a memory-based container
     for holding message payloads. Messages using this body type
     may be serialized and parsed.
 */
@@ -33,8 +35,8 @@ template<class DynamicBuffer>
 struct basic_dynamic_body
 {
     static_assert(
-        boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
-        "DynamicBuffer requirements not met");
+        net::is_dynamic_buffer<DynamicBuffer>::value,
+        "DynamicBuffer type requirements not met");
 
     /** The type of container used for the body
 
@@ -58,10 +60,10 @@ struct basic_dynamic_body
 
     /** The algorithm for parsing the body
 
-        Meets the requirements of @b BodyReader.
+        Meets the requirements of <em>BodyReader</em>.
     */
 #if BOOST_BEAST_DOXYGEN
-    using reader = implementation_defined;
+    using reader = __implementation_defined__;
 #else
     class reader
     {
@@ -79,7 +81,7 @@ struct basic_dynamic_body
         init(boost::optional<
             std::uint64_t> const&, error_code& ec)
         {
-            ec.assign(0, ec.category());
+            ec = {};
         }
 
         template<class ConstBufferSequence>
@@ -87,29 +89,21 @@ struct basic_dynamic_body
         put(ConstBufferSequence const& buffers,
             error_code& ec)
         {
-            using boost::asio::buffer_copy;
-            using boost::asio::buffer_size;
-            auto const n = buffer_size(buffers);
-            if(body_.size() > body_.max_size() - n)
+            auto const n = buffer_bytes(buffers);
+            if(beast::detail::sum_exceeds(body_.size(), n, body_.max_size()))
             {
                 ec = error::buffer_overflow;
                 return 0;
             }
-            boost::optional<typename
-                DynamicBuffer::mutable_buffers_type> b;
-            try
-            {
-                b.emplace(body_.prepare((std::min)(n,
-                    body_.max_size() - body_.size())));
-            }
-            catch(std::length_error const&)
-            {
-                ec = error::buffer_overflow;
+            auto const mb =
+                beast::detail::dynamic_buffer_prepare(
+                    body_, (std::min)(n,
+                        body_.max_size() - body_.size()),
+                            ec, error::buffer_overflow);
+            if(ec)
                 return 0;
-            }
-            ec.assign(0, ec.category());
             auto const bytes_transferred =
-                buffer_copy(*b, buffers);
+                net::buffer_copy(*mb, buffers);
             body_.commit(bytes_transferred);
             return bytes_transferred;
         }
@@ -117,17 +111,17 @@ struct basic_dynamic_body
         void
         finish(error_code& ec)
         {
-            ec.assign(0, ec.category());
+            ec = {};
         }
     };
 #endif
 
     /** The algorithm for serializing the body
 
-        Meets the requirements of @b BodyWriter.
+        Meets the requirements of <em>BodyWriter</em>.
     */
 #if BOOST_BEAST_DOXYGEN
-    using writer = implementation_defined;
+    using writer = __implementation_defined__;
 #else
     class writer
     {
@@ -147,13 +141,13 @@ struct basic_dynamic_body
         void
         init(error_code& ec)
         {
-            ec.assign(0, ec.category());
+            ec = {};
         }
 
         boost::optional<std::pair<const_buffers_type, bool>>
         get(error_code& ec)
         {
-            ec.assign(0, ec.category());
+            ec = {};
             return {{body_.data(), false}};
         }
     };