mirror of
https://github.com/boostorg/beast.git
synced 2025-08-02 14:24:31 +02:00
Add buffer_size
This commit is contained in:
@@ -6,6 +6,7 @@ Version 209:
|
|||||||
* Qualify buffer_copy, don't qualify buffer_size
|
* Qualify buffer_copy, don't qualify buffer_size
|
||||||
* Add dynamic_buffer_ref
|
* Add dynamic_buffer_ref
|
||||||
* Refactor quickref.xml
|
* Refactor quickref.xml
|
||||||
|
* Add buffer_size
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -20,6 +20,14 @@ transferred.
|
|||||||
|
|
||||||
[table Buffer Algorithms and Types
|
[table Buffer Algorithms and Types
|
||||||
[[Name][Description]]
|
[[Name][Description]]
|
||||||
|
[[
|
||||||
|
[link beast.ref.boost__beast__buffer_size `buffer_size`]
|
||||||
|
][
|
||||||
|
This is a more reliable version of
|
||||||
|
[@boost:/doc/html/boost_asio/reference/buffer_size.html `net::buffer_size`]
|
||||||
|
which is easier to use and also works for types which are convertible
|
||||||
|
to `net::const_buffer` or `net::mutable_buffer`.
|
||||||
|
]]
|
||||||
[[
|
[[
|
||||||
[link beast.ref.boost__beast__buffers_cat `buffers_cat`]
|
[link beast.ref.boost__beast__buffers_cat `buffers_cat`]
|
||||||
][
|
][
|
||||||
|
@@ -66,6 +66,7 @@
|
|||||||
<member><link linkend="beast.ref.boost__beast__bind_back_handler">bind_back_handler</link> <emphasis role="green">🞲</emphasis></member>
|
<member><link linkend="beast.ref.boost__beast__bind_back_handler">bind_back_handler</link> <emphasis role="green">🞲</emphasis></member>
|
||||||
<member><link linkend="beast.ref.boost__beast__bind_front_handler">bind_front_handler</link> <emphasis role="green">🞲</emphasis></member>
|
<member><link linkend="beast.ref.boost__beast__bind_front_handler">bind_front_handler</link> <emphasis role="green">🞲</emphasis></member>
|
||||||
<member><link linkend="beast.ref.boost__beast__bind_handler">bind_handler</link></member>
|
<member><link linkend="beast.ref.boost__beast__bind_handler">bind_handler</link></member>
|
||||||
|
<member><link linkend="beast.ref.boost__beast__buffer_size">buffer_size</link> <emphasis role="green">🞲</emphasis></member>
|
||||||
<member><link linkend="beast.ref.boost__beast__close_socket">close_socket</link> <emphasis role="green">🞲</emphasis></member>
|
<member><link linkend="beast.ref.boost__beast__close_socket">close_socket</link> <emphasis role="green">🞲</emphasis></member>
|
||||||
<member><link linkend="beast.ref.boost__beast__generic_category">generic_category</link></member>
|
<member><link linkend="beast.ref.boost__beast__generic_category">generic_category</link></member>
|
||||||
<member><link linkend="beast.ref.boost__beast__get_lowest_layer">get_lowest_layer</link> <emphasis role="green">🞲</emphasis></member>
|
<member><link linkend="beast.ref.boost__beast__get_lowest_layer">get_lowest_layer</link> <emphasis role="green">🞲</emphasis></member>
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_CORE_DETAIL_FLAT_STREAM_HPP
|
#ifndef BOOST_BEAST_CORE_DETAIL_FLAT_STREAM_HPP
|
||||||
#define BOOST_BEAST_CORE_DETAIL_FLAT_STREAM_HPP
|
#define BOOST_BEAST_CORE_DETAIL_FLAT_STREAM_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
@@ -42,7 +43,6 @@ public:
|
|||||||
auto last = net::buffer_sequence_end(buffers);
|
auto last = net::buffer_sequence_end(buffers);
|
||||||
if(first != last)
|
if(first != last)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
result.size = buffer_size(*first);
|
result.size = buffer_size(*first);
|
||||||
if(result.size < limit)
|
if(result.size < limit)
|
||||||
{
|
{
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include <boost/beast/core/dynamic_buffer_ref.hpp>
|
#include <boost/beast/core/dynamic_buffer_ref.hpp>
|
||||||
#include <boost/beast/core/async_op_base.hpp>
|
#include <boost/beast/core/async_op_base.hpp>
|
||||||
#include <boost/beast/core/bind_handler.hpp>
|
#include <boost/beast/core/bind_handler.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffers_adaptor.hpp>
|
#include <boost/beast/core/buffers_adaptor.hpp>
|
||||||
#include <boost/beast/core/buffers_prefix.hpp>
|
#include <boost/beast/core/buffers_prefix.hpp>
|
||||||
#include <boost/beast/core/buffers_suffix.hpp>
|
#include <boost/beast/core/buffers_suffix.hpp>
|
||||||
@@ -44,7 +45,6 @@ buffer_shift(MutableBuffers const& out, ConstBuffers const& in)
|
|||||||
auto out_pos = net::buffer_sequence_end(out);
|
auto out_pos = net::buffer_sequence_end(out);
|
||||||
auto const in_begin = net::buffer_sequence_begin(in);
|
auto const in_begin = net::buffer_sequence_begin(in);
|
||||||
auto const out_begin = net::buffer_sequence_begin(out);
|
auto const out_begin = net::buffer_sequence_begin(out);
|
||||||
using net::buffer_size;
|
|
||||||
BOOST_ASSERT(buffer_size(in) == buffer_size(out));
|
BOOST_ASSERT(buffer_size(in) == buffer_size(out));
|
||||||
if(in_pos == in_begin || out_pos == out_begin)
|
if(in_pos == in_begin || out_pos == out_begin)
|
||||||
return;
|
return;
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_TEST_IMPL_STREAM_HPP
|
#ifndef BOOST_BEAST_TEST_IMPL_STREAM_HPP
|
||||||
#define BOOST_BEAST_TEST_IMPL_STREAM_HPP
|
#define BOOST_BEAST_TEST_IMPL_STREAM_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/detail/stream_algorithm.hpp>
|
#include <boost/beast/core/detail/stream_algorithm.hpp>
|
||||||
#include <boost/beast/core/buffers_prefix.hpp>
|
#include <boost/beast/core/buffers_prefix.hpp>
|
||||||
|
|
||||||
@@ -110,7 +111,6 @@ stream::
|
|||||||
str() const
|
str() const
|
||||||
{
|
{
|
||||||
auto const bs = in_->b.data();
|
auto const bs = in_->b.data();
|
||||||
using net::buffer_size;
|
|
||||||
if(buffer_size(bs) == 0)
|
if(buffer_size(bs) == 0)
|
||||||
return {};
|
return {};
|
||||||
auto const b = beast::buffers_front(bs);
|
auto const b = beast::buffers_front(bs);
|
||||||
@@ -189,7 +189,6 @@ read_some(MutableBufferSequence const& buffers,
|
|||||||
"MutableBufferSequence requirements not met");
|
"MutableBufferSequence requirements not met");
|
||||||
if(in_->fc && in_->fc->fail(ec))
|
if(in_->fc && in_->fc->fail(ec))
|
||||||
return 0;
|
return 0;
|
||||||
using net::buffer_size;
|
|
||||||
if(buffer_size(buffers) == 0)
|
if(buffer_size(buffers) == 0)
|
||||||
{
|
{
|
||||||
ec.clear();
|
ec.clear();
|
||||||
@@ -252,7 +251,6 @@ async_read_some(
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock{in_->m};
|
std::unique_lock<std::mutex> lock{in_->m};
|
||||||
BOOST_ASSERT(! in_->op);
|
BOOST_ASSERT(! in_->op);
|
||||||
using net::buffer_size;
|
|
||||||
if( buffer_size(buffers) == 0 ||
|
if( buffer_size(buffers) == 0 ||
|
||||||
buffer_size(in_->b.data()) > 0)
|
buffer_size(in_->b.data()) > 0)
|
||||||
{
|
{
|
||||||
@@ -328,7 +326,6 @@ write_some(
|
|||||||
BOOST_ASSERT(out->code == status::ok);
|
BOOST_ASSERT(out->code == status::ok);
|
||||||
if(in_->fc && in_->fc->fail(ec))
|
if(in_->fc && in_->fc->fail(ec))
|
||||||
return 0;
|
return 0;
|
||||||
using net::buffer_size;
|
|
||||||
auto const n = std::min<std::size_t>(
|
auto const n = std::min<std::size_t>(
|
||||||
buffer_size(buffers), in_->write_max);
|
buffer_size(buffers), in_->write_max);
|
||||||
std::unique_lock<std::mutex> lock{out->m};
|
std::unique_lock<std::mutex> lock{out->m};
|
||||||
@@ -379,7 +376,6 @@ async_write_some(ConstBufferSequence const& buffers,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const n = std::min<std::size_t>(
|
auto const n = std::min<std::size_t>(
|
||||||
buffer_size(buffers), in_->write_max);
|
buffer_size(buffers), in_->write_max);
|
||||||
std::unique_lock<std::mutex> lock{out->m};
|
std::unique_lock<std::mutex> lock{out->m};
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include <boost/beast/core/basic_timeout_stream.hpp>
|
#include <boost/beast/core/basic_timeout_stream.hpp>
|
||||||
#include <boost/beast/core/bind_handler.hpp>
|
#include <boost/beast/core/bind_handler.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffer_traits.hpp>
|
#include <boost/beast/core/buffer_traits.hpp>
|
||||||
#include <boost/beast/core/buffered_read_stream.hpp>
|
#include <boost/beast/core/buffered_read_stream.hpp>
|
||||||
#include <boost/beast/core/buffers_adaptor.hpp>
|
#include <boost/beast/core/buffers_adaptor.hpp>
|
||||||
|
124
include/boost/beast/core/buffer_size.hpp
Normal file
124
include/boost/beast/core/buffer_size.hpp
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2016-2017 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)
|
||||||
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BOOST_BEAST_BUFFER_SIZE_HPP
|
||||||
|
#define BOOST_BEAST_BUFFER_SIZE_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
|
#include <boost/beast/core/detail/static_const.hpp>
|
||||||
|
#include <boost/beast/core/detail/type_traits.hpp>
|
||||||
|
#include <boost/asio/buffer.hpp>
|
||||||
|
#include <boost/type_traits.hpp>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace beast {
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template<class T, class = void>
|
||||||
|
struct has_buffer_size_impl : std::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct has_buffer_size_impl<T, boost::void_t<
|
||||||
|
decltype(std::declval<std::size_t&>() =
|
||||||
|
std::declval<T const&>().buffer_size_impl())>>
|
||||||
|
: std::true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
struct buffer_size_impl
|
||||||
|
{
|
||||||
|
template<
|
||||||
|
class B,
|
||||||
|
class = typename std::enable_if<
|
||||||
|
std::is_convertible<
|
||||||
|
B, net::const_buffer>::value>::type>
|
||||||
|
std::size_t
|
||||||
|
operator()(B const& b) const
|
||||||
|
{
|
||||||
|
return net::const_buffer(b).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<
|
||||||
|
class B,
|
||||||
|
class = typename std::enable_if<
|
||||||
|
! std::is_convertible<
|
||||||
|
B, net::const_buffer>::value>::type,
|
||||||
|
class = typename std::enable_if<
|
||||||
|
net::is_const_buffer_sequence<B>::value &&
|
||||||
|
! has_buffer_size_impl<B>::value>::type>
|
||||||
|
std::size_t
|
||||||
|
operator()(B const& b) const
|
||||||
|
{
|
||||||
|
using net::buffer_size;
|
||||||
|
return buffer_size(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<
|
||||||
|
class B,
|
||||||
|
class = typename std::enable_if<
|
||||||
|
! std::is_convertible<B, net::const_buffer>::value>::type,
|
||||||
|
class = typename std::enable_if<
|
||||||
|
net::is_const_buffer_sequence<B>::value>::type,
|
||||||
|
class = typename std::enable_if<
|
||||||
|
has_buffer_size_impl<B>::value>::type>
|
||||||
|
std::size_t
|
||||||
|
operator()(B const& b) const
|
||||||
|
{
|
||||||
|
return b.buffer_size_impl();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // detail
|
||||||
|
|
||||||
|
/** Return the total number of bytes in a buffer or buffer sequence
|
||||||
|
|
||||||
|
This function returns the total number of bytes in a buffer,
|
||||||
|
buffer sequence, or object convertible to a buffer. Specifically
|
||||||
|
it may be passed:
|
||||||
|
|
||||||
|
@li A <em>ConstBufferSequence</em> or <em>MutableBufferSequence</em>
|
||||||
|
|
||||||
|
@li A `net::const_buffer` or `net::mutable_buffer`
|
||||||
|
|
||||||
|
@li An object convertible to `net::const_buffer`
|
||||||
|
|
||||||
|
This function is designed as an easier-to-use replacement for
|
||||||
|
`net::buffer_size`. It recognizes customization points found through
|
||||||
|
argument-dependent lookup. The call `beast::buffer_size(b)` is
|
||||||
|
equivalent to performing:
|
||||||
|
@code
|
||||||
|
using namespace net;
|
||||||
|
buffer_size(b);
|
||||||
|
@endcode
|
||||||
|
In addition this handles types which are convertible to
|
||||||
|
`net::const_buffer`; these are not handled by `net::buffer_size`.
|
||||||
|
|
||||||
|
@note It is expected that a future version of Networking will
|
||||||
|
incorporate the features of this function.
|
||||||
|
|
||||||
|
@param buffers The buffer or buffer sequence to calculate the size of.
|
||||||
|
|
||||||
|
@return The total number of bytes in the buffer or sequence.
|
||||||
|
*/
|
||||||
|
#if BOOST_BEAST_DOXYGEN
|
||||||
|
template<class Buffers>
|
||||||
|
void
|
||||||
|
buffer_size(Buffers const& buffers);
|
||||||
|
#else
|
||||||
|
BOOST_BEAST_INLINE_VARIABLE(buffer_size, detail::buffer_size_impl)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
|
#endif
|
@@ -11,6 +11,7 @@
|
|||||||
#define BOOST_BEAST_BUFFERS_PREFIX_HPP
|
#define BOOST_BEAST_BUFFERS_PREFIX_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/detail/config.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffer_traits.hpp>
|
#include <boost/beast/core/buffer_traits.hpp>
|
||||||
#include <boost/optional/optional.hpp> // for in_place_init_t
|
#include <boost/optional/optional.hpp> // for in_place_init_t
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -128,25 +129,14 @@ public:
|
|||||||
end() const;
|
end() const;
|
||||||
|
|
||||||
#if ! BOOST_BEAST_DOXYGEN
|
#if ! BOOST_BEAST_DOXYGEN
|
||||||
template<class Buffers>
|
|
||||||
friend
|
|
||||||
std::size_t
|
std::size_t
|
||||||
buffer_size(buffers_prefix_view<Buffers> const& buffers);
|
buffer_size_impl() const noexcept
|
||||||
|
{
|
||||||
|
return size_;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BOOST_BEAST_DOXYGEN
|
|
||||||
BOOST_BEAST_DECL
|
|
||||||
std::size_t
|
|
||||||
buffer_size(buffers_prefix_view<
|
|
||||||
net::const_buffer> const& buffers);
|
|
||||||
|
|
||||||
BOOST_BEAST_DECL
|
|
||||||
std::size_t
|
|
||||||
buffer_size(buffers_prefix_view<
|
|
||||||
net::mutable_buffer> const& buffers);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
/** Returns a prefix of a constant or mutable buffer sequence.
|
/** Returns a prefix of a constant or mutable buffer sequence.
|
||||||
|
@@ -44,7 +44,6 @@ namespace beast {
|
|||||||
void send(SyncWriteStream& stream, ConstBufferSequence const& buffers)
|
void send(SyncWriteStream& stream, ConstBufferSequence const& buffers)
|
||||||
{
|
{
|
||||||
buffers_suffix<ConstBufferSequence> bs{buffers};
|
buffers_suffix<ConstBufferSequence> bs{buffers};
|
||||||
using net::buffer_size;
|
|
||||||
while(buffer_size(bs) > 0)
|
while(buffer_size(bs) > 0)
|
||||||
bs.consume(stream.write_some(bs));
|
bs.consume(stream.write_some(bs));
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#define BOOST_BEAST_BUFFERS_TO_STRING_HPP
|
#define BOOST_BEAST_BUFFERS_TO_STRING_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/detail/config.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffers_range.hpp>
|
#include <boost/beast/core/buffers_range.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -48,9 +49,8 @@ buffers_to_string(ConstBufferSequence const& buffers)
|
|||||||
net::is_const_buffer_sequence<ConstBufferSequence>::value,
|
net::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||||
"ConstBufferSequence requirements not met");
|
"ConstBufferSequence requirements not met");
|
||||||
std::string result;
|
std::string result;
|
||||||
using net::buffer_size;
|
|
||||||
result.reserve(buffer_size(buffers));
|
result.reserve(buffer_size(buffers));
|
||||||
for(auto const buffer : beast::buffers_range_ref(buffers))
|
for(auto const buffer : buffers_range_ref(buffers))
|
||||||
result.append(static_cast<char const*>(
|
result.append(static_cast<char const*>(
|
||||||
buffer.data()), buffer.size());
|
buffer.data()), buffer.size());
|
||||||
return result;
|
return result;
|
||||||
|
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <iosfwd>
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
@@ -44,151 +43,82 @@ namespace detail {
|
|||||||
template<std::size_t R>
|
template<std::size_t R>
|
||||||
class chacha
|
class chacha
|
||||||
{
|
{
|
||||||
void generate_block();
|
|
||||||
void chacha_core();
|
|
||||||
|
|
||||||
alignas(16) std::uint32_t block_[16];
|
alignas(16) std::uint32_t block_[16];
|
||||||
std::uint32_t keysetup_[8];
|
std::uint32_t keysetup_[8];
|
||||||
std::uint64_t ctr_ = 0;
|
std::uint64_t ctr_ = 0;
|
||||||
int idx_ = 16;
|
int idx_ = 16;
|
||||||
|
|
||||||
|
void generate_block()
|
||||||
|
{
|
||||||
|
std::uint32_t constexpr constants[4] = {
|
||||||
|
0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 };
|
||||||
|
std::uint32_t input[16];
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
input[i] = constants[i];
|
||||||
|
for (int i = 0; i < 8; ++i)
|
||||||
|
input[4 + i] = keysetup_[i];
|
||||||
|
input[12] = (ctr_ / 16) & 0xffffffffu;
|
||||||
|
input[13] = (ctr_ / 16) >> 32;
|
||||||
|
input[14] = input[15] = 0xdeadbeef; // Could use 128-bit counter.
|
||||||
|
for (int i = 0; i < 16; ++i)
|
||||||
|
block_[i] = input[i];
|
||||||
|
chacha_core();
|
||||||
|
for (int i = 0; i < 16; ++i)
|
||||||
|
block_[i] += input[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
void chacha_core()
|
||||||
|
{
|
||||||
|
#define BOOST_BEAST_CHACHA_ROTL32(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||||
|
|
||||||
|
#define BOOST_BEAST_CHACHA_QUARTERROUND(x, a, b, c, d) \
|
||||||
|
x[a] = x[a] + x[b]; x[d] ^= x[a]; x[d] = BOOST_BEAST_CHACHA_ROTL32(x[d], 16); \
|
||||||
|
x[c] = x[c] + x[d]; x[b] ^= x[c]; x[b] = BOOST_BEAST_CHACHA_ROTL32(x[b], 12); \
|
||||||
|
x[a] = x[a] + x[b]; x[d] ^= x[a]; x[d] = BOOST_BEAST_CHACHA_ROTL32(x[d], 8); \
|
||||||
|
x[c] = x[c] + x[d]; x[b] ^= x[c]; x[b] = BOOST_BEAST_CHACHA_ROTL32(x[b], 7)
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < R; i += 2)
|
||||||
|
{
|
||||||
|
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 0, 4, 8, 12);
|
||||||
|
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 1, 5, 9, 13);
|
||||||
|
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 2, 6, 10, 14);
|
||||||
|
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 3, 7, 11, 15);
|
||||||
|
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 0, 5, 10, 15);
|
||||||
|
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 1, 6, 11, 12);
|
||||||
|
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 2, 7, 8, 13);
|
||||||
|
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 3, 4, 9, 14);
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef BOOST_BEAST_CHACHA_QUARTERROUND
|
||||||
|
#undef BOOST_BEAST_CHACHA_ROTL32
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr std::size_t state_size = sizeof(chacha::keysetup_);
|
static constexpr std::size_t state_size = sizeof(chacha::keysetup_);
|
||||||
|
|
||||||
using result_type = std::uint32_t;
|
using result_type = std::uint32_t;
|
||||||
|
|
||||||
chacha(std::uint32_t const* v, std::uint64_t stream);
|
chacha(std::uint32_t const* v, std::uint64_t stream)
|
||||||
|
|
||||||
std::uint32_t
|
|
||||||
operator()();
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
template<std::size_t R_>
|
|
||||||
friend
|
|
||||||
bool
|
|
||||||
operator==(chacha<R_> const& lhs, chacha<R_> const& rhs);
|
|
||||||
|
|
||||||
template<std::size_t R_>
|
|
||||||
friend
|
|
||||||
bool
|
|
||||||
operator!=(chacha<R_> const& lhs, chacha<R_> const& rhs);
|
|
||||||
|
|
||||||
static
|
|
||||||
constexpr
|
|
||||||
std::uint32_t
|
|
||||||
min()
|
|
||||||
{
|
{
|
||||||
return (std::numeric_limits<std::uint32_t>::min)();
|
for (int i = 0; i < 6; ++i)
|
||||||
|
keysetup_[i] = v[i];
|
||||||
|
keysetup_[6] = v[6] + (stream & 0xffffffff);
|
||||||
|
keysetup_[7] = v[7] + ((stream >> 32) & 0xffffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
constexpr
|
|
||||||
std::uint32_t
|
std::uint32_t
|
||||||
max()
|
operator()()
|
||||||
{
|
{
|
||||||
return (std::numeric_limits<std::uint32_t>::max)();
|
if(idx_ == 16)
|
||||||
|
{
|
||||||
|
idx_ = 0;
|
||||||
|
++ctr_;
|
||||||
|
generate_block();
|
||||||
|
}
|
||||||
|
return block_[idx_++];
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<std::size_t R>
|
|
||||||
chacha<R>::
|
|
||||||
chacha(std::uint32_t const* v, std::uint64_t stream)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 6; ++i)
|
|
||||||
keysetup_[i] = v[i];
|
|
||||||
keysetup_[6] = v[6] + (stream & 0xffffffff);
|
|
||||||
keysetup_[7] = v[7] + ((stream >> 32) & 0xffffffff);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<std::size_t R>
|
|
||||||
std::uint32_t
|
|
||||||
chacha<R>::
|
|
||||||
operator()()
|
|
||||||
{
|
|
||||||
if(idx_ == 16)
|
|
||||||
{
|
|
||||||
idx_ = 0;
|
|
||||||
++ctr_;
|
|
||||||
generate_block();
|
|
||||||
}
|
|
||||||
return block_[idx_++];
|
|
||||||
}
|
|
||||||
|
|
||||||
template<std::size_t R>
|
|
||||||
void
|
|
||||||
chacha<R>::
|
|
||||||
generate_block()
|
|
||||||
{
|
|
||||||
std::uint32_t constexpr constants[4] = {
|
|
||||||
0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 };
|
|
||||||
std::uint32_t input[16];
|
|
||||||
for (int i = 0; i < 4; ++i)
|
|
||||||
input[i] = constants[i];
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
input[4 + i] = keysetup_[i];
|
|
||||||
input[12] = (ctr_ / 16) & 0xffffffffu;
|
|
||||||
input[13] = (ctr_ / 16) >> 32;
|
|
||||||
input[14] = input[15] = 0xdeadbeef; // Could use 128-bit counter.
|
|
||||||
for (int i = 0; i < 16; ++i)
|
|
||||||
block_[i] = input[i];
|
|
||||||
chacha_core();
|
|
||||||
for (int i = 0; i < 16; ++i)
|
|
||||||
block_[i] += input[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
template<std::size_t R>
|
|
||||||
void
|
|
||||||
chacha<R>::
|
|
||||||
chacha_core()
|
|
||||||
{
|
|
||||||
#define BOOST_BEAST_CHACHA_ROTL32(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
|
|
||||||
|
|
||||||
#define BOOST_BEAST_CHACHA_QUARTERROUND(x, a, b, c, d) \
|
|
||||||
x[a] = x[a] + x[b]; x[d] ^= x[a]; x[d] = BOOST_BEAST_CHACHA_ROTL32(x[d], 16); \
|
|
||||||
x[c] = x[c] + x[d]; x[b] ^= x[c]; x[b] = BOOST_BEAST_CHACHA_ROTL32(x[b], 12); \
|
|
||||||
x[a] = x[a] + x[b]; x[d] ^= x[a]; x[d] = BOOST_BEAST_CHACHA_ROTL32(x[d], 8); \
|
|
||||||
x[c] = x[c] + x[d]; x[b] ^= x[c]; x[b] = BOOST_BEAST_CHACHA_ROTL32(x[b], 7)
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < R; i += 2)
|
|
||||||
{
|
|
||||||
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 0, 4, 8, 12);
|
|
||||||
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 1, 5, 9, 13);
|
|
||||||
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 2, 6, 10, 14);
|
|
||||||
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 3, 7, 11, 15);
|
|
||||||
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 0, 5, 10, 15);
|
|
||||||
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 1, 6, 11, 12);
|
|
||||||
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 2, 7, 8, 13);
|
|
||||||
BOOST_BEAST_CHACHA_QUARTERROUND(block_, 3, 4, 9, 14);
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef BOOST_BEAST_CHACHA_QUARTERROUND
|
|
||||||
#undef BOOST_BEAST_CHACHA_ROTL32
|
|
||||||
}
|
|
||||||
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Implement <random> interface.
|
|
||||||
|
|
||||||
template<std::size_t R>
|
|
||||||
bool
|
|
||||||
operator==(chacha<R> const& lhs, chacha<R> const& rhs)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
if (lhs.keysetup_[i] != rhs.keysetup_[i])
|
|
||||||
return false;
|
|
||||||
return lhs.ctr_ == rhs.ctr_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<std::size_t R>
|
|
||||||
bool
|
|
||||||
operator!=(chacha<R> const& lhs, chacha<R> const& rhs)
|
|
||||||
{
|
|
||||||
return !(lhs == rhs);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
} // beast
|
} // beast
|
||||||
} // boost
|
} // boost
|
||||||
|
@@ -76,7 +76,7 @@ namespace net = boost::asio;
|
|||||||
#define BOOST_BEAST_INLINE_VARIABLE(name, type) \
|
#define BOOST_BEAST_INLINE_VARIABLE(name, type) \
|
||||||
inline namespace \
|
inline namespace \
|
||||||
{ \
|
{ \
|
||||||
constexpr auto &name = \
|
constexpr auto& name = \
|
||||||
::boost::beast::detail::static_const<type>::value; \
|
::boost::beast::detail::static_const<type>::value; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_IMPL_BUFFERS_ADAPTOR_HPP
|
#ifndef BOOST_BEAST_IMPL_BUFFERS_ADAPTOR_HPP
|
||||||
#define BOOST_BEAST_IMPL_BUFFERS_ADAPTOR_HPP
|
#define BOOST_BEAST_IMPL_BUFFERS_ADAPTOR_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/detail/type_traits.hpp>
|
#include <boost/beast/core/detail/type_traits.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/config/workaround.hpp>
|
#include <boost/config/workaround.hpp>
|
||||||
@@ -400,7 +401,6 @@ buffers_adaptor(MutableBufferSequence const& bs)
|
|||||||
, max_size_(
|
, max_size_(
|
||||||
[&bs]
|
[&bs]
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
return buffer_size(bs);
|
return buffer_size(bs);
|
||||||
}())
|
}())
|
||||||
{
|
{
|
||||||
@@ -418,7 +418,6 @@ buffers_adaptor(
|
|||||||
, max_size_(
|
, max_size_(
|
||||||
[&]
|
[&]
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
return buffer_size(bs_);
|
return buffer_size(bs_);
|
||||||
}())
|
}())
|
||||||
{
|
{
|
||||||
@@ -502,7 +501,6 @@ prepare(std::size_t n) ->
|
|||||||
end_ = out_;
|
end_ = out_;
|
||||||
if(end_ != net::buffer_sequence_end(bs_))
|
if(end_ != net::buffer_sequence_end(bs_))
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto size = buffer_size(*end_) - out_pos_;
|
auto size = buffer_size(*end_) - out_pos_;
|
||||||
if(n > size)
|
if(n > size)
|
||||||
{
|
{
|
||||||
@@ -545,7 +543,6 @@ commit(std::size_t n) noexcept
|
|||||||
auto const last = std::prev(end_);
|
auto const last = std::prev(end_);
|
||||||
while(out_ != last)
|
while(out_ != last)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const avail =
|
auto const avail =
|
||||||
buffer_size(*out_) - out_pos_;
|
buffer_size(*out_) - out_pos_;
|
||||||
if(n < avail)
|
if(n < avail)
|
||||||
@@ -579,7 +576,6 @@ consume(std::size_t n) noexcept
|
|||||||
{
|
{
|
||||||
while(begin_ != out_)
|
while(begin_ != out_)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const avail =
|
auto const avail =
|
||||||
buffer_size(*begin_) - in_pos_;
|
buffer_size(*begin_) - in_pos_;
|
||||||
if(n < avail)
|
if(n < avail)
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_IMPL_BUFFERS_PREFIX_HPP
|
#ifndef BOOST_BEAST_IMPL_BUFFERS_PREFIX_HPP
|
||||||
#define BOOST_BEAST_IMPL_BUFFERS_PREFIX_HPP
|
#define BOOST_BEAST_IMPL_BUFFERS_PREFIX_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/config/workaround.hpp>
|
#include <boost/config/workaround.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@@ -149,7 +150,6 @@ setup(std::size_t size)
|
|||||||
auto const last = bs_.end();
|
auto const last = bs_.end();
|
||||||
while(end_ != last)
|
while(end_ != last)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const len = buffer_size(*end_++);
|
auto const len = buffer_size(*end_++);
|
||||||
if(len >= size)
|
if(len >= size)
|
||||||
{
|
{
|
||||||
@@ -248,14 +248,6 @@ end() const ->
|
|||||||
*this, std::true_type{}};
|
*this, std::true_type{}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Buffers>
|
|
||||||
std::size_t
|
|
||||||
buffer_size(buffers_prefix_view<
|
|
||||||
Buffers> const& buffers)
|
|
||||||
{
|
|
||||||
return buffers.size_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
@@ -290,14 +282,13 @@ public:
|
|||||||
std::forward<Args>(args)...))
|
std::forward<Args>(args)...))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
std::size_t
|
std::size_t
|
||||||
buffer_size(buffers_prefix_view<
|
buffer_size_impl() const noexcept
|
||||||
net::const_buffer> const& buffers)
|
{
|
||||||
{
|
return this->size();
|
||||||
return buffers.size();
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -333,14 +324,13 @@ public:
|
|||||||
std::forward<Args>(args)...))
|
std::forward<Args>(args)...))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
std::size_t
|
std::size_t
|
||||||
buffer_size(buffers_prefix_view<
|
buffer_size_impl() const noexcept
|
||||||
net::mutable_buffer> const& buffers)
|
{
|
||||||
{
|
return this->size();
|
||||||
return buffers.size();
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
} // beast
|
} // beast
|
||||||
} // boost
|
} // boost
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP
|
#ifndef BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP
|
||||||
#define BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP
|
#define BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffer_traits.hpp>
|
#include <boost/beast/core/buffer_traits.hpp>
|
||||||
#include <boost/type_traits.hpp>
|
#include <boost/type_traits.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -206,7 +207,6 @@ consume(std::size_t amount)
|
|||||||
net::buffer_sequence_end(bs_);
|
net::buffer_sequence_end(bs_);
|
||||||
for(;amount > 0 && begin_ != end; ++begin_)
|
for(;amount > 0 && begin_ != end; ++begin_)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const len =
|
auto const len =
|
||||||
buffer_size(*begin_) - skip_;
|
buffer_size(*begin_) - skip_;
|
||||||
if(amount < len)
|
if(amount < len)
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_IMPL_MULTI_BUFFER_HPP
|
#ifndef BOOST_BEAST_IMPL_MULTI_BUFFER_HPP
|
||||||
#define BOOST_BEAST_IMPL_MULTI_BUFFER_HPP
|
#define BOOST_BEAST_IMPL_MULTI_BUFFER_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/detail/type_traits.hpp>
|
#include <boost/beast/core/detail/type_traits.hpp>
|
||||||
#include <boost/config/workaround.hpp>
|
#include <boost/config/workaround.hpp>
|
||||||
#include <boost/core/exchange.hpp>
|
#include <boost/core/exchange.hpp>
|
||||||
@@ -195,11 +196,10 @@ public:
|
|||||||
const_iterator begin() const noexcept;
|
const_iterator begin() const noexcept;
|
||||||
const_iterator end() const noexcept;
|
const_iterator end() const noexcept;
|
||||||
|
|
||||||
friend
|
|
||||||
std::size_t
|
std::size_t
|
||||||
buffer_size(readable_bytes const& buffers) noexcept
|
buffer_size() const noexcept
|
||||||
{
|
{
|
||||||
return buffers.b_->size();
|
return b_->size();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1132,7 +1132,6 @@ basic_multi_buffer<Allocator>::
|
|||||||
debug_check() const
|
debug_check() const
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
using net::buffer_size;
|
|
||||||
BOOST_ASSERT(buffer_size(data()) == in_size_);
|
BOOST_ASSERT(buffer_size(data()) == in_size_);
|
||||||
if(list_.empty())
|
if(list_.empty())
|
||||||
{
|
{
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#define BOOST_BEAST_MAKE_PRINTABLE_HPP
|
#define BOOST_BEAST_MAKE_PRINTABLE_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/detail/config.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
@@ -73,7 +74,6 @@ operator<<(std::ostream& os,
|
|||||||
void
|
void
|
||||||
print (ConstBufferSequence const& buffers)
|
print (ConstBufferSequence const& buffers)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
std::cout <<
|
std::cout <<
|
||||||
"Buffer size: " << buffer_size(buffers) << " bytes\n"
|
"Buffer size: " << buffer_size(buffers) << " bytes\n"
|
||||||
"Buffer data: '" << make_printable(buffers) << "'\n";
|
"Buffer data: '" << make_printable(buffers) << "'\n";
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#define BOOST_BEAST_HTTP_BASIC_DYNAMIC_BODY_HPP
|
#define BOOST_BEAST_HTTP_BASIC_DYNAMIC_BODY_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/detail/config.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/type_traits.hpp>
|
#include <boost/beast/core/type_traits.hpp>
|
||||||
#include <boost/beast/core/detail/buffer.hpp>
|
#include <boost/beast/core/detail/buffer.hpp>
|
||||||
#include <boost/beast/http/error.hpp>
|
#include <boost/beast/http/error.hpp>
|
||||||
@@ -88,7 +89,6 @@ struct basic_dynamic_body
|
|||||||
put(ConstBufferSequence const& buffers,
|
put(ConstBufferSequence const& buffers,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const n = buffer_size(buffers);
|
auto const n = buffer_size(buffers);
|
||||||
if(body_.size() > body_.max_size() - n)
|
if(body_.size() > body_.max_size() - n)
|
||||||
{
|
{
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#define BOOST_BEAST_HTTP_BUFFER_BODY_HPP
|
#define BOOST_BEAST_HTTP_BUFFER_BODY_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/detail/config.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/http/error.hpp>
|
#include <boost/beast/http/error.hpp>
|
||||||
#include <boost/beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
#include <boost/beast/http/type_traits.hpp>
|
#include <boost/beast/http/type_traits.hpp>
|
||||||
@@ -132,7 +133,6 @@ struct buffer_body
|
|||||||
body_.data = static_cast<char*>(
|
body_.data = static_cast<char*>(
|
||||||
body_.data) + bytes_transferred;
|
body_.data) + bytes_transferred;
|
||||||
body_.size -= bytes_transferred;
|
body_.size -= bytes_transferred;
|
||||||
using net::buffer_size;
|
|
||||||
if(bytes_transferred == buffer_size(buffers))
|
if(bytes_transferred == buffer_size(buffers))
|
||||||
ec = {};
|
ec = {};
|
||||||
else
|
else
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_HTTP_IMPL_BASIC_PARSER_IPP
|
#ifndef BOOST_BEAST_HTTP_IMPL_BASIC_PARSER_IPP
|
||||||
#define BOOST_BEAST_HTTP_IMPL_BASIC_PARSER_IPP
|
#define BOOST_BEAST_HTTP_IMPL_BASIC_PARSER_IPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/static_string.hpp>
|
#include <boost/beast/core/static_string.hpp>
|
||||||
#include <boost/beast/core/type_traits.hpp>
|
#include <boost/beast/core/type_traits.hpp>
|
||||||
#include <boost/beast/core/detail/clamp.hpp>
|
#include <boost/beast/core/detail/clamp.hpp>
|
||||||
@@ -106,7 +107,6 @@ put(ConstBufferSequence const& buffers,
|
|||||||
// single buffer
|
// single buffer
|
||||||
return put(net::const_buffer(*p), ec);
|
return put(net::const_buffer(*p), ec);
|
||||||
}
|
}
|
||||||
using net::buffer_size;
|
|
||||||
auto const size = buffer_size(buffers);
|
auto const size = buffer_size(buffers);
|
||||||
if(size <= max_stack_buffer)
|
if(size <= max_stack_buffer)
|
||||||
return put_from_stack(size, buffers, ec);
|
return put_from_stack(size, buffers, ec);
|
||||||
@@ -130,7 +130,6 @@ put(net::const_buffer const& buffer,
|
|||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(state_ != state::complete);
|
BOOST_ASSERT(state_ != state::complete);
|
||||||
using net::buffer_size;
|
|
||||||
auto p = static_cast<char const*>(buffer.data());
|
auto p = static_cast<char const*>(buffer.data());
|
||||||
auto n = buffer.size();
|
auto n = buffer.size();
|
||||||
auto const p0 = p;
|
auto const p0 = p;
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_HTTP_IMPL_CHUNK_ENCODE_IPP
|
#ifndef BOOST_BEAST_HTTP_IMPL_CHUNK_ENCODE_IPP
|
||||||
#define BOOST_BEAST_HTTP_IMPL_CHUNK_ENCODE_IPP
|
#define BOOST_BEAST_HTTP_IMPL_CHUNK_ENCODE_IPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/detail/varint.hpp>
|
#include <boost/beast/core/detail/varint.hpp>
|
||||||
#include <boost/beast/http/error.hpp>
|
#include <boost/beast/http/error.hpp>
|
||||||
#include <boost/beast/http/detail/rfc7230.hpp>
|
#include <boost/beast/http/detail/rfc7230.hpp>
|
||||||
@@ -89,11 +90,7 @@ template<class ConstBufferSequence>
|
|||||||
chunk_body<ConstBufferSequence>::
|
chunk_body<ConstBufferSequence>::
|
||||||
chunk_body(ConstBufferSequence const& buffers)
|
chunk_body(ConstBufferSequence const& buffers)
|
||||||
: view_(
|
: view_(
|
||||||
[&]
|
buffer_size(buffers),
|
||||||
{
|
|
||||||
using net::buffer_size;
|
|
||||||
return buffer_size(buffers);
|
|
||||||
}(),
|
|
||||||
net::const_buffer{nullptr, 0},
|
net::const_buffer{nullptr, 0},
|
||||||
chunk_crlf{},
|
chunk_crlf{},
|
||||||
buffers,
|
buffers,
|
||||||
@@ -107,11 +104,7 @@ chunk_body(
|
|||||||
ConstBufferSequence const& buffers,
|
ConstBufferSequence const& buffers,
|
||||||
string_view extensions)
|
string_view extensions)
|
||||||
: view_(
|
: view_(
|
||||||
[&]
|
buffer_size(buffers),
|
||||||
{
|
|
||||||
using net::buffer_size;
|
|
||||||
return buffer_size(buffers);
|
|
||||||
}(),
|
|
||||||
net::const_buffer{
|
net::const_buffer{
|
||||||
extensions.data(), extensions.size()},
|
extensions.data(), extensions.size()},
|
||||||
chunk_crlf{},
|
chunk_crlf{},
|
||||||
@@ -130,11 +123,7 @@ chunk_body(
|
|||||||
typename std::decay<ChunkExtensions>::type>>(
|
typename std::decay<ChunkExtensions>::type>>(
|
||||||
std::forward<ChunkExtensions>(extensions)))
|
std::forward<ChunkExtensions>(extensions)))
|
||||||
, view_(
|
, view_(
|
||||||
[&]
|
buffer_size(buffers),
|
||||||
{
|
|
||||||
using net::buffer_size;
|
|
||||||
return buffer_size(buffers);
|
|
||||||
}(),
|
|
||||||
exts_->str(),
|
exts_->str(),
|
||||||
chunk_crlf{},
|
chunk_crlf{},
|
||||||
buffers,
|
buffers,
|
||||||
@@ -153,11 +142,7 @@ chunk_body(
|
|||||||
typename std::decay<ChunkExtensions>::type>>(allocator,
|
typename std::decay<ChunkExtensions>::type>>(allocator,
|
||||||
std::forward<ChunkExtensions>(extensions)))
|
std::forward<ChunkExtensions>(extensions)))
|
||||||
, view_(
|
, view_(
|
||||||
[&]
|
buffer_size(buffers),
|
||||||
{
|
|
||||||
using net::buffer_size;
|
|
||||||
return buffer_size(buffers);
|
|
||||||
}(),
|
|
||||||
exts_->str(),
|
exts_->str(),
|
||||||
chunk_crlf{},
|
chunk_crlf{},
|
||||||
buffers,
|
buffers,
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_HTTP_IMPL_SERIALIZER_IPP
|
#ifndef BOOST_BEAST_HTTP_IMPL_SERIALIZER_IPP
|
||||||
#define BOOST_BEAST_HTTP_IMPL_SERIALIZER_IPP
|
#define BOOST_BEAST_HTTP_IMPL_SERIALIZER_IPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/detail/buffers_ref.hpp>
|
#include <boost/beast/core/detail/buffers_ref.hpp>
|
||||||
#include <boost/beast/http/error.hpp>
|
#include <boost/beast/http/error.hpp>
|
||||||
#include <boost/beast/http/status.hpp>
|
#include <boost/beast/http/status.hpp>
|
||||||
@@ -70,7 +71,6 @@ void
|
|||||||
serializer<isRequest, Body, Fields>::
|
serializer<isRequest, Body, Fields>::
|
||||||
next(error_code& ec, Visit&& visit)
|
next(error_code& ec, Visit&& visit)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
switch(s_)
|
switch(s_)
|
||||||
{
|
{
|
||||||
case do_construct:
|
case do_construct:
|
||||||
@@ -289,7 +289,6 @@ void
|
|||||||
serializer<isRequest, Body, Fields>::
|
serializer<isRequest, Body, Fields>::
|
||||||
consume(std::size_t n)
|
consume(std::size_t n)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
switch(s_)
|
switch(s_)
|
||||||
{
|
{
|
||||||
case do_header:
|
case do_header:
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#define BOOST_BEAST_HTTP_SPAN_BODY_HPP
|
#define BOOST_BEAST_HTTP_SPAN_BODY_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/detail/config.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/span.hpp>
|
#include <boost/beast/core/span.hpp>
|
||||||
#include <boost/beast/http/error.hpp>
|
#include <boost/beast/http/error.hpp>
|
||||||
#include <boost/beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
@@ -95,7 +96,6 @@ public:
|
|||||||
put(ConstBufferSequence const& buffers,
|
put(ConstBufferSequence const& buffers,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const n = buffer_size(buffers);
|
auto const n = buffer_size(buffers);
|
||||||
auto const len = body_.size();
|
auto const len = body_.size();
|
||||||
if(n > len)
|
if(n > len)
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#define BOOST_BEAST_HTTP_STRING_BODY_HPP
|
#define BOOST_BEAST_HTTP_STRING_BODY_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/detail/config.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/http/error.hpp>
|
#include <boost/beast/http/error.hpp>
|
||||||
#include <boost/beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
#include <boost/beast/core/buffers_range.hpp>
|
#include <boost/beast/core/buffers_range.hpp>
|
||||||
@@ -117,7 +118,6 @@ public:
|
|||||||
put(ConstBufferSequence const& buffers,
|
put(ConstBufferSequence const& buffers,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const extra = buffer_size(buffers);
|
auto const extra = buffer_size(buffers);
|
||||||
auto const size = body_.size();
|
auto const size = body_.size();
|
||||||
try
|
try
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#define BOOST_BEAST_HTTP_VECTOR_BODY_HPP
|
#define BOOST_BEAST_HTTP_VECTOR_BODY_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/detail/config.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/http/error.hpp>
|
#include <boost/beast/http/error.hpp>
|
||||||
#include <boost/beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
#include <boost/beast/core/detail/type_traits.hpp>
|
#include <boost/beast/core/detail/type_traits.hpp>
|
||||||
@@ -111,7 +112,6 @@ public:
|
|||||||
put(ConstBufferSequence const& buffers,
|
put(ConstBufferSequence const& buffers,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const n = buffer_size(buffers);
|
auto const n = buffer_size(buffers);
|
||||||
auto const len = body_.size();
|
auto const len = body_.size();
|
||||||
try
|
try
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_WEBSOCKET_DETAIL_FRAME_HPP
|
#ifndef BOOST_BEAST_WEBSOCKET_DETAIL_FRAME_HPP
|
||||||
#define BOOST_BEAST_WEBSOCKET_DETAIL_FRAME_HPP
|
#define BOOST_BEAST_WEBSOCKET_DETAIL_FRAME_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/websocket/error.hpp>
|
#include <boost/beast/websocket/error.hpp>
|
||||||
#include <boost/beast/websocket/rfc6455.hpp>
|
#include <boost/beast/websocket/rfc6455.hpp>
|
||||||
#include <boost/beast/websocket/detail/utf8_checker.hpp>
|
#include <boost/beast/websocket/detail/utf8_checker.hpp>
|
||||||
@@ -229,7 +230,6 @@ template<class Buffers>
|
|||||||
void
|
void
|
||||||
read_ping(ping_data& data, Buffers const& bs)
|
read_ping(ping_data& data, Buffers const& bs)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
BOOST_ASSERT(buffer_size(bs) <= data.max_size());
|
BOOST_ASSERT(buffer_size(bs) <= data.max_size());
|
||||||
data.resize(buffer_size(bs));
|
data.resize(buffer_size(bs));
|
||||||
net::buffer_copy(net::mutable_buffer{
|
net::buffer_copy(net::mutable_buffer{
|
||||||
@@ -246,9 +246,7 @@ read_close(
|
|||||||
Buffers const& bs,
|
Buffers const& bs,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
using namespace boost::endian;
|
using namespace boost::endian;
|
||||||
using net::buffer_size;
|
|
||||||
auto n = buffer_size(bs);
|
auto n = buffer_size(bs);
|
||||||
BOOST_ASSERT(n <= 125);
|
BOOST_ASSERT(n <= 125);
|
||||||
if(n == 0)
|
if(n == 0)
|
||||||
@@ -266,7 +264,7 @@ read_close(
|
|||||||
buffers_suffix<Buffers> cb(bs);
|
buffers_suffix<Buffers> cb(bs);
|
||||||
{
|
{
|
||||||
std::uint8_t b[2];
|
std::uint8_t b[2];
|
||||||
net::buffer_copy(buffer(b), cb);
|
net::buffer_copy(net::buffer(b), cb);
|
||||||
cr.code = big_uint16_to_native(&b[0]);
|
cr.code = big_uint16_to_native(&b[0]);
|
||||||
cb.consume(2);
|
cb.consume(2);
|
||||||
n -= 2;
|
n -= 2;
|
||||||
@@ -280,7 +278,8 @@ read_close(
|
|||||||
if(n > 0)
|
if(n > 0)
|
||||||
{
|
{
|
||||||
cr.reason.resize(n);
|
cr.reason.resize(n);
|
||||||
net::buffer_copy(buffer(&cr.reason[0], n), cb);
|
net::buffer_copy(
|
||||||
|
net::buffer(&cr.reason[0], n), cb);
|
||||||
if(! check_utf8(
|
if(! check_utf8(
|
||||||
cr.reason.data(), cr.reason.size()))
|
cr.reason.data(), cr.reason.size()))
|
||||||
{
|
{
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_WEBSOCKET_DETAIL_STREAM_BASE_HPP
|
#ifndef BOOST_BEAST_WEBSOCKET_DETAIL_STREAM_BASE_HPP
|
||||||
#define BOOST_BEAST_WEBSOCKET_DETAIL_STREAM_BASE_HPP
|
#define BOOST_BEAST_WEBSOCKET_DETAIL_STREAM_BASE_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/http/empty_body.hpp>
|
#include <boost/beast/http/empty_body.hpp>
|
||||||
#include <boost/beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
#include <boost/beast/http/string_body.hpp>
|
#include <boost/beast/http/string_body.hpp>
|
||||||
@@ -88,7 +89,6 @@ struct impl_base<true>
|
|||||||
std::size_t& total_in,
|
std::size_t& total_in,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
BOOST_ASSERT(out.size() >= 6);
|
BOOST_ASSERT(out.size() >= 6);
|
||||||
auto& zo = this->pmd_->zo;
|
auto& zo = this->pmd_->zo;
|
||||||
zlib::z_params zs;
|
zlib::z_params zs;
|
||||||
@@ -123,7 +123,6 @@ struct impl_base<true>
|
|||||||
cb.consume(zs.total_in);
|
cb.consume(zs.total_in);
|
||||||
if(zs.avail_out > 0 && fin)
|
if(zs.avail_out > 0 && fin)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const remain = buffer_size(cb);
|
auto const remain = buffer_size(cb);
|
||||||
if(remain == 0)
|
if(remain == 0)
|
||||||
{
|
{
|
||||||
@@ -144,13 +143,13 @@ struct impl_base<true>
|
|||||||
BOOST_ASSERT(! ec);
|
BOOST_ASSERT(! ec);
|
||||||
// remove flush marker
|
// remove flush marker
|
||||||
zs.total_out -= 4;
|
zs.total_out -= 4;
|
||||||
out = buffer(out.data(), zs.total_out);
|
out = net::buffer(out.data(), zs.total_out);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ec = {};
|
ec = {};
|
||||||
out = buffer(out.data(), zs.total_out);
|
out = net::buffer(out.data(), zs.total_out);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_WEBSOCKET_IMPL_ACCEPT_IPP
|
#ifndef BOOST_BEAST_WEBSOCKET_IMPL_ACCEPT_IPP
|
||||||
#define BOOST_BEAST_WEBSOCKET_IMPL_ACCEPT_IPP
|
#define BOOST_BEAST_WEBSOCKET_IMPL_ACCEPT_IPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/websocket/detail/type_traits.hpp>
|
#include <boost/beast/websocket/detail/type_traits.hpp>
|
||||||
#include <boost/beast/http/empty_body.hpp>
|
#include <boost/beast/http/empty_body.hpp>
|
||||||
#include <boost/beast/http/parser.hpp>
|
#include <boost/beast/http/parser.hpp>
|
||||||
@@ -122,7 +123,6 @@ public:
|
|||||||
void run(Buffers const& buffers)
|
void run(Buffers const& buffers)
|
||||||
{
|
{
|
||||||
error_code ec;
|
error_code ec;
|
||||||
using net::buffer_size;
|
|
||||||
auto const mb = beast::detail::dynamic_buffer_prepare(
|
auto const mb = beast::detail::dynamic_buffer_prepare(
|
||||||
ws_.impl_->rd_buf, buffer_size(buffers), ec,
|
ws_.impl_->rd_buf, buffer_size(buffers), ec,
|
||||||
error::buffer_overflow);
|
error::buffer_overflow);
|
||||||
@@ -296,7 +296,6 @@ accept(
|
|||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
"ConstBufferSequence requirements not met");
|
"ConstBufferSequence requirements not met");
|
||||||
impl_->reset();
|
impl_->reset();
|
||||||
using net::buffer_size;
|
|
||||||
auto const mb = beast::detail::dynamic_buffer_prepare(
|
auto const mb = beast::detail::dynamic_buffer_prepare(
|
||||||
impl_->rd_buf, buffer_size(buffers), ec,
|
impl_->rd_buf, buffer_size(buffers), ec,
|
||||||
error::buffer_overflow);
|
error::buffer_overflow);
|
||||||
@@ -327,7 +326,6 @@ accept_ex(
|
|||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
"ConstBufferSequence requirements not met");
|
"ConstBufferSequence requirements not met");
|
||||||
impl_->reset();
|
impl_->reset();
|
||||||
using net::buffer_size;
|
|
||||||
auto const mb = beast::detail::dynamic_buffer_prepare(
|
auto const mb = beast::detail::dynamic_buffer_prepare(
|
||||||
impl_->rd_buf, buffer_size(buffers), ec,
|
impl_->rd_buf, buffer_size(buffers), ec,
|
||||||
error::buffer_overflow);
|
error::buffer_overflow);
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_WEBSOCKET_IMPL_READ_HPP
|
#ifndef BOOST_BEAST_WEBSOCKET_IMPL_READ_HPP
|
||||||
#define BOOST_BEAST_WEBSOCKET_IMPL_READ_HPP
|
#define BOOST_BEAST_WEBSOCKET_IMPL_READ_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/websocket/teardown.hpp>
|
#include <boost/beast/websocket/teardown.hpp>
|
||||||
#include <boost/beast/websocket/detail/mask.hpp>
|
#include <boost/beast/websocket/detail/mask.hpp>
|
||||||
#include <boost/beast/core/async_op_base.hpp>
|
#include <boost/beast/core/async_op_base.hpp>
|
||||||
@@ -82,8 +83,6 @@ public:
|
|||||||
bool cont = true)
|
bool cont = true)
|
||||||
{
|
{
|
||||||
using beast::detail::clamp;
|
using beast::detail::clamp;
|
||||||
using net::buffer;
|
|
||||||
using net::buffer_size;
|
|
||||||
auto& impl = *ws_.impl_;
|
auto& impl = *ws_.impl_;
|
||||||
cont_ = cont;
|
cont_ = cont;
|
||||||
BOOST_ASIO_CORO_REENTER(*this)
|
BOOST_ASIO_CORO_REENTER(*this)
|
||||||
@@ -881,8 +880,6 @@ read_some(
|
|||||||
MutableBufferSequence>::value,
|
MutableBufferSequence>::value,
|
||||||
"MutableBufferSequence requirements not met");
|
"MutableBufferSequence requirements not met");
|
||||||
using beast::detail::clamp;
|
using beast::detail::clamp;
|
||||||
using net::buffer;
|
|
||||||
using net::buffer_size;
|
|
||||||
close_code code{};
|
close_code code{};
|
||||||
std::size_t bytes_written = 0;
|
std::size_t bytes_written = 0;
|
||||||
ec = {};
|
ec = {};
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_WEBSOCKET_IMPL_STREAM_HPP
|
#ifndef BOOST_BEAST_WEBSOCKET_IMPL_STREAM_HPP
|
||||||
#define BOOST_BEAST_WEBSOCKET_IMPL_STREAM_HPP
|
#define BOOST_BEAST_WEBSOCKET_IMPL_STREAM_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/websocket/rfc6455.hpp>
|
#include <boost/beast/websocket/rfc6455.hpp>
|
||||||
#include <boost/beast/websocket/teardown.hpp>
|
#include <boost/beast/websocket/teardown.hpp>
|
||||||
#include <boost/beast/websocket/detail/hybi13.hpp>
|
#include <boost/beast/websocket/detail/hybi13.hpp>
|
||||||
@@ -282,7 +283,6 @@ parse_fh(
|
|||||||
DynamicBuffer& b,
|
DynamicBuffer& b,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
if(buffer_size(b.data()) < 2)
|
if(buffer_size(b.data()) < 2)
|
||||||
{
|
{
|
||||||
// need more bytes
|
// need more bytes
|
||||||
|
@@ -57,7 +57,6 @@ public:
|
|||||||
error_code ec = {},
|
error_code ec = {},
|
||||||
std::size_t bytes_transferred = 0)
|
std::size_t bytes_transferred = 0)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
using tcp = net::ip::tcp;
|
using tcp = net::ip::tcp;
|
||||||
BOOST_ASIO_CORO_REENTER(*this)
|
BOOST_ASIO_CORO_REENTER(*this)
|
||||||
{
|
{
|
||||||
@@ -130,7 +129,6 @@ teardown(
|
|||||||
net::ip::tcp::socket& socket,
|
net::ip::tcp::socket& socket,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
if(role == role_type::server)
|
if(role == role_type::server)
|
||||||
socket.shutdown(
|
socket.shutdown(
|
||||||
net::ip::tcp::socket::shutdown_send, ec);
|
net::ip::tcp::socket::shutdown_send, ec);
|
||||||
@@ -140,7 +138,7 @@ teardown(
|
|||||||
{
|
{
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
auto const bytes_transferred =
|
auto const bytes_transferred =
|
||||||
socket.read_some(buffer(buf), ec);
|
socket.read_some(net::buffer(buf), ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
{
|
{
|
||||||
if(ec != net::error::eof)
|
if(ec != net::error::eof)
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include <boost/beast/websocket/detail/mask.hpp>
|
#include <boost/beast/websocket/detail/mask.hpp>
|
||||||
#include <boost/beast/core/async_op_base.hpp>
|
#include <boost/beast/core/async_op_base.hpp>
|
||||||
#include <boost/beast/core/bind_handler.hpp>
|
#include <boost/beast/core/bind_handler.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffers_cat.hpp>
|
#include <boost/beast/core/buffers_cat.hpp>
|
||||||
#include <boost/beast/core/buffers_prefix.hpp>
|
#include <boost/beast/core/buffers_prefix.hpp>
|
||||||
#include <boost/beast/core/buffers_range.hpp>
|
#include <boost/beast/core/buffers_range.hpp>
|
||||||
@@ -88,7 +89,6 @@ operator()(
|
|||||||
bool cont)
|
bool cont)
|
||||||
{
|
{
|
||||||
using beast::detail::clamp;
|
using beast::detail::clamp;
|
||||||
using net::buffer_size;
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
do_nomask_nofrag,
|
do_nomask_nofrag,
|
||||||
@@ -470,7 +470,6 @@ write_some(bool fin,
|
|||||||
ConstBufferSequence>::value,
|
ConstBufferSequence>::value,
|
||||||
"ConstBufferSequence requirements not met");
|
"ConstBufferSequence requirements not met");
|
||||||
using beast::detail::clamp;
|
using beast::detail::clamp;
|
||||||
using net::buffer_size;
|
|
||||||
std::size_t bytes_transferred = 0;
|
std::size_t bytes_transferred = 0;
|
||||||
ec = {};
|
ec = {};
|
||||||
// Make sure the stream is open
|
// Make sure the stream is open
|
||||||
|
@@ -31,6 +31,7 @@ add_executable (tests-beast-core
|
|||||||
async_op_base.cpp
|
async_op_base.cpp
|
||||||
basic_timeout_stream.cpp
|
basic_timeout_stream.cpp
|
||||||
bind_handler.cpp
|
bind_handler.cpp
|
||||||
|
buffer_size.cpp
|
||||||
buffer_traits.cpp
|
buffer_traits.cpp
|
||||||
buffered_read_stream.cpp
|
buffered_read_stream.cpp
|
||||||
buffers_adapter.cpp
|
buffers_adapter.cpp
|
||||||
|
@@ -19,6 +19,7 @@ local SOURCES =
|
|||||||
async_op_base.cpp
|
async_op_base.cpp
|
||||||
basic_timeout_stream.cpp
|
basic_timeout_stream.cpp
|
||||||
bind_handler.cpp
|
bind_handler.cpp
|
||||||
|
buffer_size.cpp
|
||||||
buffer_traits.cpp
|
buffer_traits.cpp
|
||||||
buffered_read_stream.cpp
|
buffered_read_stream.cpp
|
||||||
buffers_adapter.cpp
|
buffers_adapter.cpp
|
||||||
|
98
test/beast/core/buffer_size.cpp
Normal file
98
test/beast/core/buffer_size.cpp
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2018 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)
|
||||||
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
|
// Test that header file is self-contained.
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
|
|
||||||
|
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||||
|
#include <boost/beast/core/detail/type_traits.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace beast {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct sequence
|
||||||
|
{
|
||||||
|
struct value_type
|
||||||
|
{
|
||||||
|
operator net::const_buffer() const noexcept
|
||||||
|
{
|
||||||
|
return {"Hello, world!", 13};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
using const_iterator = value_type const*;
|
||||||
|
|
||||||
|
const_iterator begin() const noexcept
|
||||||
|
{
|
||||||
|
return &v_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const_iterator end() const noexcept
|
||||||
|
{
|
||||||
|
return begin() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
value_type v_;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct not_sequence
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // (anon)
|
||||||
|
|
||||||
|
class buffer_size_test : public beast::unit_test::suite
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void
|
||||||
|
testJavadocs()
|
||||||
|
{
|
||||||
|
pass();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
testFunction()
|
||||||
|
{
|
||||||
|
BEAST_EXPECT(buffer_size(
|
||||||
|
net::const_buffer("Hello, world!", 13)) == 13);
|
||||||
|
|
||||||
|
BEAST_EXPECT(buffer_size(
|
||||||
|
net::mutable_buffer{}) == 0);
|
||||||
|
|
||||||
|
{
|
||||||
|
sequence s;
|
||||||
|
BEAST_EXPECT(buffer_size(s) == 13);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::array<net::const_buffer, 2> s({{
|
||||||
|
net::const_buffer("Hello, world!", 13),
|
||||||
|
net::const_buffer("Hello, world!", 13)}});
|
||||||
|
BEAST_EXPECT(buffer_size(s) == 26);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT(! detail::is_invocable<
|
||||||
|
detail::buffer_size_impl,
|
||||||
|
std::size_t(not_sequence const&)>::value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void run() override
|
||||||
|
{
|
||||||
|
testFunction();
|
||||||
|
testJavadocs();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BEAST_DEFINE_TESTSUITE(beast,core,buffer_size);
|
||||||
|
|
||||||
|
} // beast
|
||||||
|
} // boost
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <boost/beast/core/detail/config.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffer_traits.hpp>
|
#include <boost/beast/core/buffer_traits.hpp>
|
||||||
#include <boost/beast/core/buffers_to_string.hpp>
|
#include <boost/beast/core/buffers_to_string.hpp>
|
||||||
#include <boost/beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
@@ -116,7 +117,6 @@ void test_mutable_buffers(
|
|||||||
MutableBufferSequence const& b,
|
MutableBufferSequence const& b,
|
||||||
net::mutable_buffer)
|
net::mutable_buffer)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
string_view src = "Hello, world!";
|
string_view src = "Hello, world!";
|
||||||
BOOST_ASSERT(buffer_size(b) <= src.size());
|
BOOST_ASSERT(buffer_size(b) <= src.size());
|
||||||
if(src.size() > buffer_size(b))
|
if(src.size() > buffer_size(b))
|
||||||
@@ -139,8 +139,6 @@ test_buffer_sequence(
|
|||||||
net::is_const_buffer_sequence<
|
net::is_const_buffer_sequence<
|
||||||
ConstBufferSequence>::value);
|
ConstBufferSequence>::value);
|
||||||
|
|
||||||
using net::buffer_size;
|
|
||||||
|
|
||||||
using iterator = decltype(
|
using iterator = decltype(
|
||||||
net::buffer_sequence_begin(buffers));
|
net::buffer_sequence_begin(buffers));
|
||||||
BEAST_EXPECT(sizeof(iterator) > 0);
|
BEAST_EXPECT(sizeof(iterator) > 0);
|
||||||
@@ -183,7 +181,6 @@ test_buffer_sequence(
|
|||||||
|
|
||||||
// bidirectional
|
// bidirectional
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const first =
|
auto const first =
|
||||||
net::buffer_sequence_begin(buffers);
|
net::buffer_sequence_begin(buffers);
|
||||||
auto const last =
|
auto const last =
|
||||||
@@ -290,8 +287,6 @@ test_mutable_dynamic_buffer(
|
|||||||
MutableDynamicBuffer const& b0,
|
MutableDynamicBuffer const& b0,
|
||||||
std::true_type)
|
std::true_type)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(
|
BOOST_STATIC_ASSERT(
|
||||||
net::is_mutable_buffer_sequence<typename
|
net::is_mutable_buffer_sequence<typename
|
||||||
MutableDynamicBuffer::mutable_data_type>::value);
|
MutableDynamicBuffer::mutable_data_type>::value);
|
||||||
@@ -372,8 +367,6 @@ void
|
|||||||
test_dynamic_buffer(
|
test_dynamic_buffer(
|
||||||
DynamicBuffer const& b0)
|
DynamicBuffer const& b0)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(
|
BOOST_STATIC_ASSERT(
|
||||||
net::is_dynamic_buffer<DynamicBuffer>::value);
|
net::is_dynamic_buffer<DynamicBuffer>::value);
|
||||||
|
|
||||||
|
@@ -80,7 +80,6 @@ public:
|
|||||||
void
|
void
|
||||||
on_read(error_code ec, std::size_t)
|
on_read(error_code ec, std::size_t)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
if(! ec)
|
if(! ec)
|
||||||
{
|
{
|
||||||
suite_.expect(s_ ==
|
suite_.expect(s_ ==
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "buffer_test.hpp"
|
#include "buffer_test.hpp"
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/multi_buffer.hpp>
|
#include <boost/beast/core/multi_buffer.hpp>
|
||||||
#include <boost/beast/core/ostream.hpp>
|
#include <boost/beast/core/ostream.hpp>
|
||||||
#include <boost/beast/core/read_size.hpp>
|
#include <boost/beast/core/read_size.hpp>
|
||||||
@@ -42,8 +43,6 @@ public:
|
|||||||
void
|
void
|
||||||
testSpecial()
|
testSpecial()
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
|
|
||||||
char s1[13];
|
char s1[13];
|
||||||
buffers_triple tb1(s1, sizeof(s1));
|
buffers_triple tb1(s1, sizeof(s1));
|
||||||
BEAST_EXPECT(buffer_size(tb1) == sizeof(s1));
|
BEAST_EXPECT(buffer_size(tb1) == sizeof(s1));
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "buffer_test.hpp"
|
#include "buffer_test.hpp"
|
||||||
|
|
||||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffers_prefix.hpp>
|
#include <boost/beast/core/buffers_prefix.hpp>
|
||||||
#include <boost/beast/core/buffers_suffix.hpp>
|
#include <boost/beast/core/buffers_suffix.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
@@ -155,8 +156,6 @@ public:
|
|||||||
void
|
void
|
||||||
testEmpty()
|
testEmpty()
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
|
|
||||||
struct empty_sequence
|
struct empty_sequence
|
||||||
{
|
{
|
||||||
using value_type = net::const_buffer;
|
using value_type = net::const_buffer;
|
||||||
@@ -275,19 +274,14 @@ public:
|
|||||||
void
|
void
|
||||||
testGccWarning1()
|
testGccWarning1()
|
||||||
{
|
{
|
||||||
using boost::beast::buffers_cat;
|
|
||||||
using boost::beast::buffers_suffix;
|
|
||||||
using net::buffer;
|
|
||||||
using net::const_buffer;
|
|
||||||
|
|
||||||
char out[64];
|
char out[64];
|
||||||
std::array<const_buffer, 2> buffers{
|
std::array<net::const_buffer, 2> buffers{
|
||||||
{buffer("Hello, "), buffer("world!")}};
|
{net::buffer("Hello, "), net::buffer("world!")}};
|
||||||
std::size_t i = 3;
|
std::size_t i = 3;
|
||||||
buffers_suffix<std::array<const_buffer, 2>> cb(buffers);
|
buffers_suffix<std::array<net::const_buffer, 2>> cb(buffers);
|
||||||
cb.consume(i);
|
cb.consume(i);
|
||||||
net::buffer_copy(
|
net::buffer_copy(
|
||||||
buffer(out),
|
net::buffer(out),
|
||||||
buffers_cat(cb, cb));
|
buffers_cat(cb, cb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "buffer_test.hpp"
|
#include "buffer_test.hpp"
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffers_to_string.hpp>
|
#include <boost/beast/core/buffers_to_string.hpp>
|
||||||
#include <boost/beast/core/type_traits.hpp>
|
#include <boost/beast/core/type_traits.hpp>
|
||||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||||
@@ -89,7 +90,6 @@ public:
|
|||||||
void
|
void
|
||||||
testPrefixes()
|
testPrefixes()
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
std::string s = "Hello, world";
|
std::string s = "Hello, world";
|
||||||
BEAST_EXPECT(s.size() == 12);
|
BEAST_EXPECT(s.size() == 12);
|
||||||
for(std::size_t x = 1; x < 4; ++x) {
|
for(std::size_t x = 1; x < 4; ++x) {
|
||||||
@@ -118,8 +118,6 @@ public:
|
|||||||
|
|
||||||
void testEmpty()
|
void testEmpty()
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
|
|
||||||
auto pb0 = buffers_prefix(0, net::mutable_buffer{});
|
auto pb0 = buffers_prefix(0, net::mutable_buffer{});
|
||||||
BEAST_EXPECT(buffer_size(pb0) == 0);
|
BEAST_EXPECT(buffer_size(pb0) == 0);
|
||||||
auto pb1 = buffers_prefix(1, net::mutable_buffer{});
|
auto pb1 = buffers_prefix(1, net::mutable_buffer{});
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "buffer_test.hpp"
|
#include "buffer_test.hpp"
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffers_cat.hpp>
|
#include <boost/beast/core/buffers_cat.hpp>
|
||||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
@@ -80,7 +81,6 @@ public:
|
|||||||
|
|
||||||
// empty sequence
|
// empty sequence
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
buffers_suffix<net::mutable_buffer> cb(
|
buffers_suffix<net::mutable_buffer> cb(
|
||||||
net::mutable_buffer{});
|
net::mutable_buffer{});
|
||||||
BEAST_EXPECT(buffer_size(cb) == 0);
|
BEAST_EXPECT(buffer_size(cb) == 0);
|
||||||
@@ -113,7 +113,6 @@ public:
|
|||||||
void
|
void
|
||||||
testMatrix()
|
testMatrix()
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
char buf[12];
|
char buf[12];
|
||||||
std::string const s = "Hello, world";
|
std::string const s = "Hello, world";
|
||||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "buffer_test.hpp"
|
#include "buffer_test.hpp"
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/ostream.hpp>
|
#include <boost/beast/core/ostream.hpp>
|
||||||
#include <boost/beast/core/read_size.hpp>
|
#include <boost/beast/core/read_size.hpp>
|
||||||
#include <boost/beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
@@ -40,8 +41,6 @@ public:
|
|||||||
void
|
void
|
||||||
testMembers()
|
testMembers()
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
|
|
||||||
string_view const s = "Hello, world!";
|
string_view const s = "Hello, world!";
|
||||||
|
|
||||||
// flat_static_buffer_base
|
// flat_static_buffer_base
|
||||||
|
@@ -9,7 +9,9 @@
|
|||||||
|
|
||||||
// Test that header file is self-contained.
|
// Test that header file is self-contained.
|
||||||
#include <boost/beast/core/make_printable.hpp>
|
#include <boost/beast/core/make_printable.hpp>
|
||||||
|
|
||||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@@ -25,7 +27,6 @@ public:
|
|||||||
void
|
void
|
||||||
print (ConstBufferSequence const& buffers)
|
print (ConstBufferSequence const& buffers)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
std::cout <<
|
std::cout <<
|
||||||
"Buffer size: " << buffer_size(buffers) << " bytes\n"
|
"Buffer size: " << buffer_size(buffers) << " bytes\n"
|
||||||
"Buffer data: '" << make_printable(buffers) << "'\n";
|
"Buffer data: '" << make_printable(buffers) << "'\n";
|
||||||
@@ -40,8 +41,6 @@ public:
|
|||||||
void
|
void
|
||||||
testMakePrintable()
|
testMakePrintable()
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
|
|
||||||
char buf[13];
|
char buf[13];
|
||||||
buffers_triple b(buf, sizeof(buf));
|
buffers_triple b(buf, sizeof(buf));
|
||||||
string_view src = "Hello, world!";
|
string_view src = "Hello, world!";
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "buffer_test.hpp"
|
#include "buffer_test.hpp"
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/ostream.hpp>
|
#include <boost/beast/core/ostream.hpp>
|
||||||
#include <boost/beast/core/read_size.hpp>
|
#include <boost/beast/core/read_size.hpp>
|
||||||
#include <boost/beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
@@ -577,8 +578,6 @@ public:
|
|||||||
void
|
void
|
||||||
testMatrix1()
|
testMatrix1()
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
|
|
||||||
string_view s = "Hello, world";
|
string_view s = "Hello, world";
|
||||||
BEAST_EXPECT(s.size() == 12);
|
BEAST_EXPECT(s.size() == 12);
|
||||||
for(std::size_t i = 1; i < 12; ++i) {
|
for(std::size_t i = 1; i < 12; ++i) {
|
||||||
@@ -621,8 +620,6 @@ public:
|
|||||||
testMatrix2()
|
testMatrix2()
|
||||||
{
|
{
|
||||||
using namespace test;
|
using namespace test;
|
||||||
using net::buffer;
|
|
||||||
using net::buffer_size;
|
|
||||||
std::string const s = "Hello, world";
|
std::string const s = "Hello, world";
|
||||||
BEAST_EXPECT(s.size() == 12);
|
BEAST_EXPECT(s.size() == 12);
|
||||||
for(std::size_t i = 1; i < 12; ++i) {
|
for(std::size_t i = 1; i < 12; ++i) {
|
||||||
@@ -649,7 +646,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto d = b.prepare(x);
|
auto d = b.prepare(x);
|
||||||
BEAST_EXPECT(buffer_size(d) == x);
|
BEAST_EXPECT(buffer_size(d) == x);
|
||||||
b.commit(buffer_copy(d, buffer(s.data(), x)));
|
b.commit(buffer_copy(d, net::buffer(s.data(), x)));
|
||||||
}
|
}
|
||||||
BEAST_EXPECT(b.size() == x);
|
BEAST_EXPECT(b.size() == x);
|
||||||
BEAST_EXPECT(buffer_size(b.data()) == b.size());
|
BEAST_EXPECT(buffer_size(b.data()) == b.size());
|
||||||
@@ -668,7 +665,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto d = b.prepare(y);
|
auto d = b.prepare(y);
|
||||||
BEAST_EXPECT(buffer_size(d) == y);
|
BEAST_EXPECT(buffer_size(d) == y);
|
||||||
b.commit(buffer_copy(d, buffer(s.data()+x, y)));
|
b.commit(buffer_copy(d, net::buffer(s.data()+x, y)));
|
||||||
}
|
}
|
||||||
b.commit(1);
|
b.commit(1);
|
||||||
BEAST_EXPECT(b.size() == x + y);
|
BEAST_EXPECT(b.size() == x + y);
|
||||||
@@ -688,7 +685,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto d = b.prepare(z);
|
auto d = b.prepare(z);
|
||||||
BEAST_EXPECT(buffer_size(d) == z);
|
BEAST_EXPECT(buffer_size(d) == z);
|
||||||
b.commit(buffer_copy(d, buffer(s.data()+x+y, z)));
|
b.commit(buffer_copy(d, net::buffer(s.data()+x+y, z)));
|
||||||
}
|
}
|
||||||
b.commit(2);
|
b.commit(2);
|
||||||
BEAST_EXPECT(b.size() == x + y + z);
|
BEAST_EXPECT(b.size() == x + y + z);
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "buffer_test.hpp"
|
#include "buffer_test.hpp"
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/ostream.hpp>
|
#include <boost/beast/core/ostream.hpp>
|
||||||
#include <boost/beast/core/read_size.hpp>
|
#include <boost/beast/core/read_size.hpp>
|
||||||
#include <boost/beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
@@ -44,8 +45,6 @@ public:
|
|||||||
void
|
void
|
||||||
testMembers()
|
testMembers()
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
|
|
||||||
string_view const s = "Hello, world!";
|
string_view const s = "Hello, world!";
|
||||||
|
|
||||||
// static_buffer_base
|
// static_buffer_base
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "message_fuzz.hpp"
|
#include "message_fuzz.hpp"
|
||||||
#include "test_parser.hpp"
|
#include "test_parser.hpp"
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffers_cat.hpp>
|
#include <boost/beast/core/buffers_cat.hpp>
|
||||||
#include <boost/beast/core/buffers_prefix.hpp>
|
#include <boost/beast/core/buffers_prefix.hpp>
|
||||||
#include <boost/beast/core/buffers_suffix.hpp>
|
#include <boost/beast/core/buffers_suffix.hpp>
|
||||||
@@ -156,7 +157,6 @@ public:
|
|||||||
parsegrind(ConstBufferSequence const& buffers,
|
parsegrind(ConstBufferSequence const& buffers,
|
||||||
Test const& test, bool skip = false)
|
Test const& test, bool skip = false)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const size = buffer_size(buffers);
|
auto const size = buffer_size(buffers);
|
||||||
for(std::size_t i = 1; i < size - 1; ++i)
|
for(std::size_t i = 1; i < size - 1; ++i)
|
||||||
{
|
{
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
// Test that header file is self-contained.
|
// Test that header file is self-contained.
|
||||||
#include <boost/beast/http/file_body.hpp>
|
#include <boost/beast/http/file_body.hpp>
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffers_prefix.hpp>
|
#include <boost/beast/core/buffers_prefix.hpp>
|
||||||
#include <boost/beast/core/file_stdio.hpp>
|
#include <boost/beast/core/file_stdio.hpp>
|
||||||
#include <boost/beast/core/flat_buffer.hpp>
|
#include <boost/beast/core/flat_buffer.hpp>
|
||||||
@@ -33,7 +34,6 @@ public:
|
|||||||
void
|
void
|
||||||
operator()(error_code&, ConstBufferSequence const& buffers)
|
operator()(error_code&, ConstBufferSequence const& buffers)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
buffer.commit(net::buffer_copy(
|
buffer.commit(net::buffer_copy(
|
||||||
buffer.prepare(buffer_size(buffers)),
|
buffer.prepare(buffer_size(buffers)),
|
||||||
buffers));
|
buffers));
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||||
#include <boost/beast/test/yield_to.hpp>
|
#include <boost/beast/test/yield_to.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffers_suffix.hpp>
|
#include <boost/beast/core/buffers_suffix.hpp>
|
||||||
#include <boost/beast/core/flat_buffer.hpp>
|
#include <boost/beast/core/flat_buffer.hpp>
|
||||||
#include <boost/beast/core/multi_buffer.hpp>
|
#include <boost/beast/core/multi_buffer.hpp>
|
||||||
@@ -51,7 +52,6 @@ public:
|
|||||||
basic_parser<isRequest, Derived>& p,
|
basic_parser<isRequest, Derived>& p,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
buffers_suffix<ConstBufferSequence> cb{buffers};
|
buffers_suffix<ConstBufferSequence> cb{buffers};
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
@@ -75,13 +75,12 @@ public:
|
|||||||
void
|
void
|
||||||
doMatrix(string_view s0, F const& f)
|
doMatrix(string_view s0, F const& f)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
// parse a single buffer
|
// parse a single buffer
|
||||||
{
|
{
|
||||||
auto s = s0;
|
auto s = s0;
|
||||||
error_code ec;
|
error_code ec;
|
||||||
parser_type<isRequest> p;
|
parser_type<isRequest> p;
|
||||||
put(buffer(s.data(), s.size()), p, ec);
|
put(net::buffer(s.data(), s.size()), p, ec);
|
||||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||||
return;
|
return;
|
||||||
f(p);
|
f(p);
|
||||||
@@ -94,7 +93,7 @@ public:
|
|||||||
parser_type<isRequest> p;
|
parser_type<isRequest> p;
|
||||||
p.eager(true);
|
p.eager(true);
|
||||||
auto used =
|
auto used =
|
||||||
p.put(buffer(s.data(), n), ec);
|
p.put(net::buffer(s.data(), n), ec);
|
||||||
s.remove_prefix(used);
|
s.remove_prefix(used);
|
||||||
if(ec == error::need_more)
|
if(ec == error::need_more)
|
||||||
ec = {};
|
ec = {};
|
||||||
@@ -102,7 +101,7 @@ public:
|
|||||||
continue;
|
continue;
|
||||||
BEAST_EXPECT(! p.is_done());
|
BEAST_EXPECT(! p.is_done());
|
||||||
used = p.put(
|
used = p.put(
|
||||||
buffer(s.data(), s.size()), ec);
|
net::buffer(s.data(), s.size()), ec);
|
||||||
s.remove_prefix(used);
|
s.remove_prefix(used);
|
||||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||||
continue;
|
continue;
|
||||||
|
@@ -430,7 +430,6 @@ public:
|
|||||||
void
|
void
|
||||||
readgrind(string_view s, Pred&& pred)
|
readgrind(string_view s, Pred&& pred)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
for(std::size_t n = 1; n < s.size() - 1; ++n)
|
for(std::size_t n = 1; n < s.size() - 1; ++n)
|
||||||
{
|
{
|
||||||
Parser p;
|
Parser p;
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
// Test that header file is self-contained.
|
// Test that header file is self-contained.
|
||||||
#include <boost/beast/http/serializer.hpp>
|
#include <boost/beast/http/serializer.hpp>
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/http/string_body.hpp>
|
#include <boost/beast/http/string_body.hpp>
|
||||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||||
|
|
||||||
@@ -91,7 +92,6 @@ public:
|
|||||||
operator()(error_code&,
|
operator()(error_code&,
|
||||||
ConstBufferSequence const& buffers)
|
ConstBufferSequence const& buffers)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
size = buffer_size(buffers);
|
size = buffer_size(buffers);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
// Test that header file is self-contained.
|
// Test that header file is self-contained.
|
||||||
#include <boost/beast/http/span_body.hpp>
|
#include <boost/beast/http/span_body.hpp>
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||||
|
|
||||||
@@ -23,7 +24,6 @@ struct span_body_test
|
|||||||
void
|
void
|
||||||
testSpanBody()
|
testSpanBody()
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
{
|
{
|
||||||
using B = span_body<char const>;
|
using B = span_body<char const>;
|
||||||
request<B> req;
|
request<B> req;
|
||||||
|
@@ -124,10 +124,10 @@ public:
|
|||||||
std::false_type, // isSplit
|
std::false_type, // isSplit
|
||||||
std::false_type) // isFinalEmpty
|
std::false_type) // isFinalEmpty
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
if(body_.s.empty())
|
if(body_.s.empty())
|
||||||
return boost::none;
|
return boost::none;
|
||||||
return {{buffer(body_.s.data(), body_.s.size()), false}};
|
return {{net::buffer(
|
||||||
|
body_.s.data(), body_.s.size()), false}};
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::pair<const_buffers_type, bool>>
|
boost::optional<std::pair<const_buffers_type, bool>>
|
||||||
@@ -135,14 +135,13 @@ public:
|
|||||||
std::false_type, // isSplit
|
std::false_type, // isSplit
|
||||||
std::true_type) // isFinalEmpty
|
std::true_type) // isFinalEmpty
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
if(body_.s.empty())
|
if(body_.s.empty())
|
||||||
return boost::none;
|
return boost::none;
|
||||||
switch(step_)
|
switch(step_)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
step_ = 1;
|
step_ = 1;
|
||||||
return {{buffer(
|
return {{net::buffer(
|
||||||
body_.s.data(), body_.s.size()), true}};
|
body_.s.data(), body_.s.size()), true}};
|
||||||
default:
|
default:
|
||||||
return boost::none;
|
return boost::none;
|
||||||
@@ -154,7 +153,6 @@ public:
|
|||||||
std::true_type, // isSplit
|
std::true_type, // isSplit
|
||||||
std::false_type) // isFinalEmpty
|
std::false_type) // isFinalEmpty
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
auto const n = (body_.s.size() + 1) / 2;
|
auto const n = (body_.s.size() + 1) / 2;
|
||||||
switch(step_)
|
switch(step_)
|
||||||
{
|
{
|
||||||
@@ -162,10 +160,10 @@ public:
|
|||||||
if(n == 0)
|
if(n == 0)
|
||||||
return boost::none;
|
return boost::none;
|
||||||
step_ = 1;
|
step_ = 1;
|
||||||
return {{buffer(body_.s.data(), n),
|
return {{net::buffer(body_.s.data(), n),
|
||||||
body_.s.size() > 1}};
|
body_.s.size() > 1}};
|
||||||
default:
|
default:
|
||||||
return {{buffer(body_.s.data() + n,
|
return {{net::buffer(body_.s.data() + n,
|
||||||
body_.s.size() - n), false}};
|
body_.s.size() - n), false}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +173,6 @@ public:
|
|||||||
std::true_type, // isSplit
|
std::true_type, // isSplit
|
||||||
std::true_type) // isFinalEmpty
|
std::true_type) // isFinalEmpty
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
auto const n = (body_.s.size() + 1) / 2;
|
auto const n = (body_.s.size() + 1) / 2;
|
||||||
switch(step_)
|
switch(step_)
|
||||||
{
|
{
|
||||||
@@ -183,11 +180,11 @@ public:
|
|||||||
if(n == 0)
|
if(n == 0)
|
||||||
return boost::none;
|
return boost::none;
|
||||||
step_ = body_.s.size() > 1 ? 1 : 2;
|
step_ = body_.s.size() > 1 ? 1 : 2;
|
||||||
return {{buffer(body_.s.data(), n), true}};
|
return {{net::buffer(body_.s.data(), n), true}};
|
||||||
case 1:
|
case 1:
|
||||||
BOOST_ASSERT(body_.s.size() > 1);
|
BOOST_ASSERT(body_.s.size() > 1);
|
||||||
step_ = 2;
|
step_ = 2;
|
||||||
return {{buffer(body_.s.data() + n,
|
return {{net::buffer(body_.s.data() + n,
|
||||||
body_.s.size() - n), true}};
|
body_.s.size() - n), true}};
|
||||||
default:
|
default:
|
||||||
return boost::none;
|
return boost::none;
|
||||||
|
@@ -171,8 +171,6 @@ public:
|
|||||||
void
|
void
|
||||||
testSuspend()
|
testSuspend()
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
|
|
||||||
// suspend on ping
|
// suspend on ping
|
||||||
doFailLoop([&](test::fail_count& fc)
|
doFailLoop([&](test::fail_count& fc)
|
||||||
{
|
{
|
||||||
@@ -374,7 +372,7 @@ public:
|
|||||||
"\x88\x00", 2});
|
"\x88\x00", 2});
|
||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
std::string const s = "Hello, world!";
|
std::string const s = "Hello, world!";
|
||||||
ws.async_write(buffer(s),
|
ws.async_write(net::buffer(s),
|
||||||
[&](error_code ec, std::size_t n)
|
[&](error_code ec, std::size_t n)
|
||||||
{
|
{
|
||||||
if(ec)
|
if(ec)
|
||||||
@@ -419,7 +417,7 @@ public:
|
|||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
multi_buffer b;
|
multi_buffer b;
|
||||||
std::string const s = "Hello, world!";
|
std::string const s = "Hello, world!";
|
||||||
ws.async_write(buffer(s),
|
ws.async_write(net::buffer(s),
|
||||||
[&](error_code ec, std::size_t n)
|
[&](error_code ec, std::size_t n)
|
||||||
{
|
{
|
||||||
if(ec)
|
if(ec)
|
||||||
@@ -479,7 +477,7 @@ public:
|
|||||||
system_error{ec});
|
system_error{ec});
|
||||||
++count;
|
++count;
|
||||||
});
|
});
|
||||||
ws.async_write(buffer(s),
|
ws.async_write(net::buffer(s),
|
||||||
[&](error_code ec, std::size_t)
|
[&](error_code ec, std::size_t)
|
||||||
{
|
{
|
||||||
if(ec != net::error::operation_aborted)
|
if(ec != net::error::operation_aborted)
|
||||||
@@ -527,7 +525,7 @@ public:
|
|||||||
BEAST_EXPECT(
|
BEAST_EXPECT(
|
||||||
ec == net::error::operation_aborted);
|
ec == net::error::operation_aborted);
|
||||||
});
|
});
|
||||||
ws.async_write(buffer(s),
|
ws.async_write(net::buffer(s),
|
||||||
[&](error_code ec, std::size_t n)
|
[&](error_code ec, std::size_t n)
|
||||||
{
|
{
|
||||||
if(ec)
|
if(ec)
|
||||||
@@ -588,7 +586,7 @@ public:
|
|||||||
system_error{ec});
|
system_error{ec});
|
||||||
++count;
|
++count;
|
||||||
});
|
});
|
||||||
ws.async_write(buffer(s),
|
ws.async_write(net::buffer(s),
|
||||||
[&](error_code ec, std::size_t)
|
[&](error_code ec, std::size_t)
|
||||||
{
|
{
|
||||||
if(ec != net::error::operation_aborted)
|
if(ec != net::error::operation_aborted)
|
||||||
|
@@ -75,8 +75,6 @@ public:
|
|||||||
void
|
void
|
||||||
doTestRead(Wrap const& w)
|
doTestRead(Wrap const& w)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
|
|
||||||
permessage_deflate pmd;
|
permessage_deflate pmd;
|
||||||
pmd.client_enable = false;
|
pmd.client_enable = false;
|
||||||
pmd.server_enable = false;
|
pmd.server_enable = false;
|
||||||
@@ -230,7 +228,7 @@ public:
|
|||||||
std::string const s(2000, '*');
|
std::string const s(2000, '*');
|
||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
ws.binary(false);
|
ws.binary(false);
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
multi_buffer b;
|
multi_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(ws.got_text());
|
BEAST_EXPECT(ws.got_text());
|
||||||
@@ -285,7 +283,7 @@ public:
|
|||||||
std::string const s = "Hello, world!";
|
std::string const s = "Hello, world!";
|
||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
ws.binary(false);
|
ws.binary(false);
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
multi_buffer b(3);
|
multi_buffer b(3);
|
||||||
@@ -306,7 +304,7 @@ public:
|
|||||||
auto const s = std::string(2000, '*') +
|
auto const s = std::string(2000, '*') +
|
||||||
random_string();
|
random_string();
|
||||||
ws.text(true);
|
ws.text(true);
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
doReadTest(w, ws, close_code::bad_payload);
|
doReadTest(w, ws, close_code::bad_payload);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -363,7 +361,7 @@ public:
|
|||||||
{
|
{
|
||||||
std::string const s =
|
std::string const s =
|
||||||
"Hello, world!" "\xc0";
|
"Hello, world!" "\xc0";
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
doReadTest(w, ws, close_code::bad_payload);
|
doReadTest(w, ws, close_code::bad_payload);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -437,8 +435,6 @@ public:
|
|||||||
void
|
void
|
||||||
doTestReadDeflate(Wrap const& w)
|
doTestReadDeflate(Wrap const& w)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
|
|
||||||
permessage_deflate pmd;
|
permessage_deflate pmd;
|
||||||
pmd.client_enable = true;
|
pmd.client_enable = true;
|
||||||
pmd.server_enable = true;
|
pmd.server_enable = true;
|
||||||
@@ -451,7 +447,7 @@ public:
|
|||||||
[&](ws_type_t<true>& ws)
|
[&](ws_type_t<true>& ws)
|
||||||
{
|
{
|
||||||
std::string const s = std::string(128, '*');
|
std::string const s = std::string(128, '*');
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
ws.read_message_max(32);
|
ws.read_message_max(32);
|
||||||
doFailTest(w, ws, error::message_too_big);
|
doFailTest(w, ws, error::message_too_big);
|
||||||
});
|
});
|
||||||
@@ -490,7 +486,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto const& s = random_string();
|
auto const& s = random_string();
|
||||||
ws.binary(true);
|
ws.binary(true);
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
multi_buffer b;
|
multi_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
||||||
@@ -504,15 +500,13 @@ public:
|
|||||||
permessage_deflate const& pmd,
|
permessage_deflate const& pmd,
|
||||||
Wrap const& w)
|
Wrap const& w)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
|
|
||||||
// message
|
// message
|
||||||
doTest(pmd, [&](ws_type& ws)
|
doTest(pmd, [&](ws_type& ws)
|
||||||
{
|
{
|
||||||
std::string const s = "Hello, world!";
|
std::string const s = "Hello, world!";
|
||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
ws.binary(false);
|
ws.binary(false);
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
multi_buffer b;
|
multi_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(ws.got_text());
|
BEAST_EXPECT(ws.got_text());
|
||||||
@@ -533,7 +527,7 @@ public:
|
|||||||
std::string const s = "Hello, world!";
|
std::string const s = "Hello, world!";
|
||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
ws.binary(false);
|
ws.binary(false);
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
multi_buffer b;
|
multi_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(ws.got_text());
|
BEAST_EXPECT(ws.got_text());
|
||||||
@@ -552,7 +546,7 @@ public:
|
|||||||
{
|
{
|
||||||
std::string const s = "";
|
std::string const s = "";
|
||||||
ws.text(true);
|
ws.text(true);
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
multi_buffer b;
|
multi_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(ws.got_text());
|
BEAST_EXPECT(ws.got_text());
|
||||||
@@ -563,10 +557,10 @@ public:
|
|||||||
doTest(pmd, [&](ws_type& ws)
|
doTest(pmd, [&](ws_type& ws)
|
||||||
{
|
{
|
||||||
std::string const s = "Hello";
|
std::string const s = "Hello";
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
char buf[3];
|
char buf[3];
|
||||||
auto const bytes_written =
|
auto const bytes_written =
|
||||||
w.read_some(ws, buffer(buf, sizeof(buf)));
|
w.read_some(ws, net::buffer(buf, sizeof(buf)));
|
||||||
BEAST_EXPECT(bytes_written > 0);
|
BEAST_EXPECT(bytes_written > 0);
|
||||||
BEAST_EXPECT(
|
BEAST_EXPECT(
|
||||||
string_view(buf, 3).substr(0, bytes_written) ==
|
string_view(buf, 3).substr(0, bytes_written) ==
|
||||||
@@ -577,7 +571,7 @@ public:
|
|||||||
doTest(pmd, [&](ws_type& ws)
|
doTest(pmd, [&](ws_type& ws)
|
||||||
{
|
{
|
||||||
std::string const s = "Hello, world!";
|
std::string const s = "Hello, world!";
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
multi_buffer b;
|
multi_buffer b;
|
||||||
auto bytes_written =
|
auto bytes_written =
|
||||||
w.read_some(ws, 3, b);
|
w.read_some(ws, 3, b);
|
||||||
@@ -593,7 +587,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto const& s = random_string();
|
auto const& s = random_string();
|
||||||
ws.binary(true);
|
ws.binary(true);
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
multi_buffer b;
|
multi_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
||||||
@@ -605,7 +599,7 @@ public:
|
|||||||
std::string const s = "\x03\xea\xf0\x28\x8c\xbc";
|
std::string const s = "\x03\xea\xf0\x28\x8c\xbc";
|
||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
ws.text(true);
|
ws.text(true);
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
doReadTest(w, ws, close_code::bad_payload);
|
doReadTest(w, ws, close_code::bad_payload);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -613,8 +607,6 @@ public:
|
|||||||
void
|
void
|
||||||
testRead()
|
testRead()
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
|
|
||||||
doTestRead<false>(SyncClient{});
|
doTestRead<false>(SyncClient{});
|
||||||
doTestRead<true>(SyncClient{});
|
doTestRead<true>(SyncClient{});
|
||||||
doTestReadDeflate(SyncClient{});
|
doTestReadDeflate(SyncClient{});
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
|
|
||||||
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/asio/io_context.hpp>
|
#include <boost/asio/io_context.hpp>
|
||||||
#include <boost/asio/strand.hpp>
|
#include <boost/asio/strand.hpp>
|
||||||
#include <boost/asio/write.hpp>
|
#include <boost/asio/write.hpp>
|
||||||
@@ -26,8 +27,6 @@ public:
|
|||||||
void
|
void
|
||||||
testSuspend()
|
testSuspend()
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
#if 1
|
|
||||||
// suspend on read block
|
// suspend on read block
|
||||||
doFailLoop([&](test::fail_count& fc)
|
doFailLoop([&](test::fail_count& fc)
|
||||||
{
|
{
|
||||||
@@ -59,12 +58,10 @@ public:
|
|||||||
ioc.run();
|
ioc.run();
|
||||||
BEAST_EXPECT(count == 2);
|
BEAST_EXPECT(count == 2);
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
|
|
||||||
// suspend on release read block
|
// suspend on release read block
|
||||||
doFailLoop([&](test::fail_count& fc)
|
doFailLoop([&](test::fail_count& fc)
|
||||||
{
|
{
|
||||||
//log << "fc.count()==" << fc.count() << std::endl;
|
|
||||||
echo_server es{log};
|
echo_server es{log};
|
||||||
net::io_context ioc;
|
net::io_context ioc;
|
||||||
stream<test::stream> ws{ioc, fc};
|
stream<test::stream> ws{ioc, fc};
|
||||||
@@ -93,7 +90,6 @@ public:
|
|||||||
BEAST_EXPECT(count == 2);
|
BEAST_EXPECT(count == 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
#if 1
|
|
||||||
// suspend on write pong
|
// suspend on write pong
|
||||||
doFailLoop([&](test::fail_count& fc)
|
doFailLoop([&](test::fail_count& fc)
|
||||||
{
|
{
|
||||||
@@ -118,7 +114,7 @@ public:
|
|||||||
++count;
|
++count;
|
||||||
});
|
});
|
||||||
BEAST_EXPECT(ws.impl_->rd_block.is_locked());
|
BEAST_EXPECT(ws.impl_->rd_block.is_locked());
|
||||||
ws.async_write(buffer(s),
|
ws.async_write(net::buffer(s),
|
||||||
[&](error_code ec, std::size_t n)
|
[&](error_code ec, std::size_t n)
|
||||||
{
|
{
|
||||||
if(ec)
|
if(ec)
|
||||||
@@ -217,7 +213,6 @@ public:
|
|||||||
ioc.run();
|
ioc.run();
|
||||||
BEAST_EXPECT(count == 2);
|
BEAST_EXPECT(count == 2);
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BEAST_TEST_WEBSOCKET_TEST_HPP
|
#ifndef BEAST_TEST_WEBSOCKET_TEST_HPP
|
||||||
#define BEAST_TEST_WEBSOCKET_TEST_HPP
|
#define BEAST_TEST_WEBSOCKET_TEST_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffers_prefix.hpp>
|
#include <boost/beast/core/buffers_prefix.hpp>
|
||||||
#include <boost/beast/core/buffers_to_string.hpp>
|
#include <boost/beast/core/buffers_to_string.hpp>
|
||||||
#include <boost/beast/core/ostream.hpp>
|
#include <boost/beast/core/ostream.hpp>
|
||||||
@@ -434,7 +435,6 @@ public:
|
|||||||
DynamicBuffer& buffer,
|
DynamicBuffer& buffer,
|
||||||
ConstBufferSequence const& buffers)
|
ConstBufferSequence const& buffers)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
buffer.commit(net::buffer_copy(
|
buffer.commit(net::buffer_copy(
|
||||||
buffer.prepare(buffer_size(buffers)),
|
buffer.prepare(buffer_size(buffers)),
|
||||||
buffers));
|
buffers));
|
||||||
|
@@ -26,8 +26,6 @@ public:
|
|||||||
void
|
void
|
||||||
doTestWrite(Wrap const& w)
|
doTestWrite(Wrap const& w)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
|
|
||||||
permessage_deflate pmd;
|
permessage_deflate pmd;
|
||||||
pmd.client_enable = false;
|
pmd.client_enable = false;
|
||||||
pmd.server_enable = false;
|
pmd.server_enable = false;
|
||||||
@@ -59,7 +57,7 @@ public:
|
|||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
ws.binary(false);
|
ws.binary(false);
|
||||||
std::string const s = "Hello, world!";
|
std::string const s = "Hello, world!";
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
multi_buffer b;
|
multi_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(ws.got_text());
|
BEAST_EXPECT(ws.got_text());
|
||||||
@@ -85,8 +83,8 @@ public:
|
|||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
ws.binary(false);
|
ws.binary(false);
|
||||||
std::string const s = "Hello, world!";
|
std::string const s = "Hello, world!";
|
||||||
w.write_some(ws, false, buffer(s.data(), 5));
|
w.write_some(ws, false, net::buffer(s.data(), 5));
|
||||||
w.write_some(ws, true, buffer(s.data() + 5, s.size() - 5));
|
w.write_some(ws, true, net::buffer(s.data() + 5, s.size() - 5));
|
||||||
multi_buffer b;
|
multi_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(ws.got_text());
|
BEAST_EXPECT(ws.got_text());
|
||||||
@@ -101,8 +99,8 @@ public:
|
|||||||
std::size_t const chop = 3;
|
std::size_t const chop = 3;
|
||||||
BOOST_ASSERT(chop < s.size());
|
BOOST_ASSERT(chop < s.size());
|
||||||
w.write_some(ws, false,
|
w.write_some(ws, false,
|
||||||
buffer(s.data(), chop));
|
net::buffer(s.data(), chop));
|
||||||
w.write_some(ws, true, buffer(
|
w.write_some(ws, true, net::buffer(
|
||||||
s.data() + chop, s.size() - chop));
|
s.data() + chop, s.size() - chop));
|
||||||
flat_buffer b;
|
flat_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
@@ -115,7 +113,7 @@ public:
|
|||||||
{
|
{
|
||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
std::string const s = "Hello";
|
std::string const s = "Hello";
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
flat_buffer b;
|
flat_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
||||||
@@ -128,7 +126,7 @@ public:
|
|||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
ws.write_buffer_size(16);
|
ws.write_buffer_size(16);
|
||||||
std::string const s(32, '*');
|
std::string const s(32, '*');
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
flat_buffer b;
|
flat_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
||||||
@@ -140,7 +138,7 @@ public:
|
|||||||
{
|
{
|
||||||
ws.auto_fragment(true);
|
ws.auto_fragment(true);
|
||||||
std::string const s(16384, '*');
|
std::string const s(16384, '*');
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
flat_buffer b;
|
flat_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
||||||
@@ -158,7 +156,7 @@ public:
|
|||||||
w.accept(ws);
|
w.accept(ws);
|
||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
std::string const s = "Hello";
|
std::string const s = "Hello";
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
flat_buffer b;
|
flat_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
||||||
@@ -184,7 +182,7 @@ public:
|
|||||||
w.accept(ws);
|
w.accept(ws);
|
||||||
ws.auto_fragment(true);
|
ws.auto_fragment(true);
|
||||||
std::string const s(16384, '*');
|
std::string const s(16384, '*');
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
flat_buffer b;
|
flat_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
||||||
@@ -203,8 +201,6 @@ public:
|
|||||||
void
|
void
|
||||||
doTestWriteDeflate(Wrap const& w)
|
doTestWriteDeflate(Wrap const& w)
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
|
|
||||||
permessage_deflate pmd;
|
permessage_deflate pmd;
|
||||||
pmd.client_enable = true;
|
pmd.client_enable = true;
|
||||||
pmd.server_enable = true;
|
pmd.server_enable = true;
|
||||||
@@ -215,7 +211,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto const& s = random_string();
|
auto const& s = random_string();
|
||||||
ws.binary(true);
|
ws.binary(true);
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
flat_buffer b;
|
flat_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
||||||
@@ -230,8 +226,8 @@ public:
|
|||||||
// This call should produce no
|
// This call should produce no
|
||||||
// output due to compression latency.
|
// output due to compression latency.
|
||||||
w.write_some(ws, false,
|
w.write_some(ws, false,
|
||||||
buffer(s.data(), chop));
|
net::buffer(s.data(), chop));
|
||||||
w.write_some(ws, true, buffer(
|
w.write_some(ws, true, net::buffer(
|
||||||
s.data() + chop, s.size() - chop));
|
s.data() + chop, s.size() - chop));
|
||||||
flat_buffer b;
|
flat_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
@@ -244,7 +240,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto const& s = random_string();
|
auto const& s = random_string();
|
||||||
ws.binary(true);
|
ws.binary(true);
|
||||||
w.write(ws, buffer(s));
|
w.write(ws, net::buffer(s));
|
||||||
flat_buffer b;
|
flat_buffer b;
|
||||||
w.read(ws, b);
|
w.read(ws, b);
|
||||||
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
BEAST_EXPECT(buffers_to_string(b.data()) == s);
|
||||||
@@ -254,8 +250,6 @@ public:
|
|||||||
void
|
void
|
||||||
testWrite()
|
testWrite()
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
|
|
||||||
doTestWrite<false>(SyncClient{});
|
doTestWrite<false>(SyncClient{});
|
||||||
doTestWrite<true>(SyncClient{});
|
doTestWrite<true>(SyncClient{});
|
||||||
doTestWriteDeflate(SyncClient{});
|
doTestWriteDeflate(SyncClient{});
|
||||||
@@ -271,8 +265,6 @@ public:
|
|||||||
void
|
void
|
||||||
testWriteSuspend()
|
testWriteSuspend()
|
||||||
{
|
{
|
||||||
using net::buffer;
|
|
||||||
|
|
||||||
// suspend on ping
|
// suspend on ping
|
||||||
doFailLoop([&](test::fail_count& fc)
|
doFailLoop([&](test::fail_count& fc)
|
||||||
{
|
{
|
||||||
@@ -392,7 +384,7 @@ public:
|
|||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
std::string const s(16384, '*');
|
std::string const s(16384, '*');
|
||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
ws.async_write(buffer(s),
|
ws.async_write(net::buffer(s),
|
||||||
[&](error_code ec, std::size_t n)
|
[&](error_code ec, std::size_t n)
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
@@ -426,7 +418,7 @@ public:
|
|||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
std::string const s(16384, '*');
|
std::string const s(16384, '*');
|
||||||
ws.auto_fragment(true);
|
ws.auto_fragment(true);
|
||||||
ws.async_write(buffer(s),
|
ws.async_write(net::buffer(s),
|
||||||
[&](error_code ec, std::size_t n)
|
[&](error_code ec, std::size_t n)
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
@@ -459,7 +451,7 @@ public:
|
|||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
std::string const s(16384, '*');
|
std::string const s(16384, '*');
|
||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
ws.async_write(buffer(s),
|
ws.async_write(net::buffer(s),
|
||||||
[&](error_code ec, std::size_t n)
|
[&](error_code ec, std::size_t n)
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
@@ -491,7 +483,7 @@ public:
|
|||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
std::string const s(16384, '*');
|
std::string const s(16384, '*');
|
||||||
ws.auto_fragment(true);
|
ws.auto_fragment(true);
|
||||||
ws.async_write(buffer(s),
|
ws.async_write(net::buffer(s),
|
||||||
[&](error_code ec, std::size_t n)
|
[&](error_code ec, std::size_t n)
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
@@ -529,7 +521,7 @@ public:
|
|||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
auto const& s = random_string();
|
auto const& s = random_string();
|
||||||
ws.binary(true);
|
ws.binary(true);
|
||||||
ws.async_write(buffer(s),
|
ws.async_write(net::buffer(s),
|
||||||
[&](error_code ec, std::size_t n)
|
[&](error_code ec, std::size_t n)
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include "test/beast/http/message_fuzz.hpp"
|
#include "test/beast/http/message_fuzz.hpp"
|
||||||
|
|
||||||
#include <boost/beast/http.hpp>
|
#include <boost/beast/http.hpp>
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/buffers_suffix.hpp>
|
#include <boost/beast/core/buffers_suffix.hpp>
|
||||||
#include <boost/beast/core/buffers_to_string.hpp>
|
#include <boost/beast/core/buffers_to_string.hpp>
|
||||||
#include <boost/beast/core/ostream.hpp>
|
#include <boost/beast/core/ostream.hpp>
|
||||||
@@ -76,7 +77,6 @@ public:
|
|||||||
basic_parser<isRequest, Derived>& parser,
|
basic_parser<isRequest, Derived>& parser,
|
||||||
error_code& ec)
|
error_code& ec)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
beast::buffers_suffix<
|
beast::buffers_suffix<
|
||||||
ConstBufferSequence> cb{buffers};
|
ConstBufferSequence> cb{buffers};
|
||||||
std::size_t used = 0;
|
std::size_t used = 0;
|
||||||
|
@@ -115,7 +115,7 @@ class connection
|
|||||||
test_buffer const& tb_;
|
test_buffer const& tb_;
|
||||||
net::strand<
|
net::strand<
|
||||||
net::io_context::executor_type> strand_;
|
net::io_context::executor_type> strand_;
|
||||||
boost::beast::multi_buffer buffer_;
|
beast::multi_buffer buffer_;
|
||||||
std::mt19937_64 rng_;
|
std::mt19937_64 rng_;
|
||||||
std::size_t count_ = 0;
|
std::size_t count_ = 0;
|
||||||
std::size_t bytes_ = 0;
|
std::size_t bytes_ = 0;
|
||||||
@@ -187,11 +187,10 @@ private:
|
|||||||
void
|
void
|
||||||
do_write()
|
do_write()
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
std::geometric_distribution<std::size_t> dist{
|
std::geometric_distribution<std::size_t> dist{
|
||||||
double(4) / buffer_size(tb_)};
|
double(4) / beast::buffer_size(tb_)};
|
||||||
ws_.async_write_some(true,
|
ws_.async_write_some(true,
|
||||||
boost::beast::buffers_prefix(dist(rng_), tb_),
|
beast::buffers_prefix(dist(rng_), tb_),
|
||||||
alloc_.wrap(std::bind(
|
alloc_.wrap(std::bind(
|
||||||
&connection::on_write,
|
&connection::on_write,
|
||||||
shared_from_this(),
|
shared_from_this(),
|
||||||
@@ -281,7 +280,7 @@ throughput(
|
|||||||
int
|
int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
boost::beast::unit_test::dstream dout(std::cerr);
|
beast::unit_test::dstream dout(std::cerr);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@@ -95,8 +95,7 @@ std::string string_from_buffers (ConstBufferSequence const& buffers)
|
|||||||
|
|
||||||
// optimization: reserve all the space for the string first
|
// optimization: reserve all the space for the string first
|
||||||
std::string result;
|
std::string result;
|
||||||
using net::buffer_size; // buffer_size is a customization point,
|
result.reserve(beast::buffer_size(buffers)); // beast version of net::buffer_size
|
||||||
result.reserve(buffer_size(buffers)); // called without namespace qualification
|
|
||||||
|
|
||||||
// iterate over each buffer in the sequence and append it to the string
|
// iterate over each buffer in the sequence and append it to the string
|
||||||
for(auto it = net::buffer_sequence_begin(buffers); // returns an iterator to beginning of the sequence
|
for(auto it = net::buffer_sequence_begin(buffers); // returns an iterator to beginning of the sequence
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
// Official repository: https://github.com/boostorg/beast
|
// Official repository: https://github.com/boostorg/beast
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <boost/beast/core/buffer_size.hpp>
|
||||||
#include <boost/beast/core/error.hpp>
|
#include <boost/beast/core/error.hpp>
|
||||||
#include <boost/beast/core/file_base.hpp>
|
#include <boost/beast/core/file_base.hpp>
|
||||||
#include <boost/beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
@@ -164,7 +165,6 @@ struct BodyReader
|
|||||||
// The specification requires this to indicate "no error"
|
// The specification requires this to indicate "no error"
|
||||||
ec = {};
|
ec = {};
|
||||||
|
|
||||||
using net::buffer_size;
|
|
||||||
return buffer_size(buffers);
|
return buffer_size(buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -272,7 +272,6 @@ void fxx() {
|
|||||||
auto const cb3 = get_next_chunk_body();
|
auto const cb3 = get_next_chunk_body();
|
||||||
|
|
||||||
// Manually emit a chunk by first writing the chunk-size header with the correct size
|
// Manually emit a chunk by first writing the chunk-size header with the correct size
|
||||||
using net::buffer_size;
|
|
||||||
net::write(sock, chunk_header{
|
net::write(sock, chunk_header{
|
||||||
buffer_size(cb1) +
|
buffer_size(cb1) +
|
||||||
buffer_size(cb2) +
|
buffer_size(cb2) +
|
||||||
@@ -368,7 +367,6 @@ print_cxx14(message<isRequest, Body, Fields> const& m)
|
|||||||
{
|
{
|
||||||
ec = {};
|
ec = {};
|
||||||
std::cout << buffers(buffer);
|
std::cout << buffers(buffer);
|
||||||
using net::buffer_size;
|
|
||||||
sr.consume(buffer_size(buffer));
|
sr.consume(buffer_size(buffer));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -396,7 +394,6 @@ struct lambda
|
|||||||
{
|
{
|
||||||
ec = {};
|
ec = {};
|
||||||
std::cout << buffers(buffer);
|
std::cout << buffers(buffer);
|
||||||
using net::buffer_size;
|
|
||||||
sr.consume(buffer_size(buffer));
|
sr.consume(buffer_size(buffer));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -438,7 +435,6 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
|
|||||||
{
|
{
|
||||||
ec = {};
|
ec = {};
|
||||||
std::cout << buffers(buffer);
|
std::cout << buffers(buffer);
|
||||||
using net::buffer_size;
|
|
||||||
sr.consume(buffer_size(buffer));
|
sr.consume(buffer_size(buffer));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -453,7 +449,6 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
|
|||||||
{
|
{
|
||||||
ec = {};
|
ec = {};
|
||||||
std::cout << buffers(buffer);
|
std::cout << buffers(buffer);
|
||||||
using net::buffer_size;
|
|
||||||
sr.consume(buffer_size(buffer));
|
sr.consume(buffer_size(buffer));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -202,7 +202,6 @@ boost::ignore_unused(ec);
|
|||||||
// This will cause the message to be broken up into multiple frames.
|
// This will cause the message to be broken up into multiple frames.
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
if(buffer_size(cb) > 512)
|
if(buffer_size(cb) > 512)
|
||||||
{
|
{
|
||||||
// There are more than 512 bytes left to send, just
|
// There are more than 512 bytes left to send, just
|
||||||
|
Reference in New Issue
Block a user