Add buffer_size

This commit is contained in:
Vinnie Falco
2019-02-03 12:59:11 -08:00
parent 64149f434a
commit 35dbd140d4
64 changed files with 427 additions and 379 deletions
@@ -10,6 +10,7 @@
#ifndef 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 <cstdlib>
@@ -42,7 +43,6 @@ public:
auto last = net::buffer_sequence_end(buffers);
if(first != last)
{
using net::buffer_size;
result.size = buffer_size(*first);
if(result.size < limit)
{
@@ -13,6 +13,7 @@
#include <boost/beast/core/dynamic_buffer_ref.hpp>
#include <boost/beast/core/async_op_base.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_prefix.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 const in_begin = net::buffer_sequence_begin(in);
auto const out_begin = net::buffer_sequence_begin(out);
using net::buffer_size;
BOOST_ASSERT(buffer_size(in) == buffer_size(out));
if(in_pos == in_begin || out_pos == out_begin)
return;
@@ -10,6 +10,7 @@
#ifndef 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/buffers_prefix.hpp>
@@ -110,7 +111,6 @@ stream::
str() const
{
auto const bs = in_->b.data();
using net::buffer_size;
if(buffer_size(bs) == 0)
return {};
auto const b = beast::buffers_front(bs);
@@ -189,7 +189,6 @@ read_some(MutableBufferSequence const& buffers,
"MutableBufferSequence requirements not met");
if(in_->fc && in_->fc->fail(ec))
return 0;
using net::buffer_size;
if(buffer_size(buffers) == 0)
{
ec.clear();
@@ -252,7 +251,6 @@ async_read_some(
{
std::unique_lock<std::mutex> lock{in_->m};
BOOST_ASSERT(! in_->op);
using net::buffer_size;
if( buffer_size(buffers) == 0 ||
buffer_size(in_->b.data()) > 0)
{
@@ -328,7 +326,6 @@ write_some(
BOOST_ASSERT(out->code == status::ok);
if(in_->fc && in_->fc->fail(ec))
return 0;
using net::buffer_size;
auto const n = std::min<std::size_t>(
buffer_size(buffers), in_->write_max);
std::unique_lock<std::mutex> lock{out->m};
@@ -379,7 +376,6 @@ async_write_some(ConstBufferSequence const& buffers,
}
else
{
using net::buffer_size;
auto const n = std::min<std::size_t>(
buffer_size(buffers), in_->write_max);
std::unique_lock<std::mutex> lock{out->m};
+1
View File
@@ -14,6 +14,7 @@
#include <boost/beast/core/basic_timeout_stream.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/buffered_read_stream.hpp>
#include <boost/beast/core/buffers_adaptor.hpp>
+124
View 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
+5 -15
View File
@@ -11,6 +11,7 @@
#define BOOST_BEAST_BUFFERS_PREFIX_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/optional/optional.hpp> // for in_place_init_t
#include <algorithm>
@@ -128,25 +129,14 @@ public:
end() const;
#if ! BOOST_BEAST_DOXYGEN
template<class Buffers>
friend
std::size_t
buffer_size(buffers_prefix_view<Buffers> const& buffers);
buffer_size_impl() const noexcept
{
return size_;
}
#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.
@@ -44,7 +44,6 @@ namespace beast {
void send(SyncWriteStream& stream, ConstBufferSequence const& buffers)
{
buffers_suffix<ConstBufferSequence> bs{buffers};
using net::buffer_size;
while(buffer_size(bs) > 0)
bs.consume(stream.write_some(bs));
}
@@ -11,6 +11,7 @@
#define BOOST_BEAST_BUFFERS_TO_STRING_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffers_range.hpp>
#include <boost/asio/buffer.hpp>
#include <string>
@@ -48,9 +49,8 @@ buffers_to_string(ConstBufferSequence const& buffers)
net::is_const_buffer_sequence<ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
std::string result;
using net::buffer_size;
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*>(
buffer.data()), buffer.size());
return result;
+58 -128
View File
@@ -35,7 +35,6 @@
#include <cstdint>
#include <limits>
#include <iosfwd>
namespace boost {
namespace beast {
@@ -44,151 +43,82 @@ namespace detail {
template<std::size_t R>
class chacha
{
void generate_block();
void chacha_core();
alignas(16) std::uint32_t block_[16];
std::uint32_t keysetup_[8];
std::uint64_t ctr_ = 0;
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:
static constexpr std::size_t state_size = sizeof(chacha::keysetup_);
using result_type = std::uint32_t;
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()
chacha(std::uint32_t const* v, std::uint64_t stream)
{
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
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
} // beast
} // boost
+1 -1
View File
@@ -76,7 +76,7 @@ namespace net = boost::asio;
#define BOOST_BEAST_INLINE_VARIABLE(name, type) \
inline namespace \
{ \
constexpr auto &name = \
constexpr auto& name = \
::boost::beast::detail::static_const<type>::value; \
}
@@ -10,6 +10,7 @@
#ifndef 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/asio/buffer.hpp>
#include <boost/config/workaround.hpp>
@@ -400,7 +401,6 @@ buffers_adaptor(MutableBufferSequence const& bs)
, max_size_(
[&bs]
{
using net::buffer_size;
return buffer_size(bs);
}())
{
@@ -418,7 +418,6 @@ buffers_adaptor(
, max_size_(
[&]
{
using net::buffer_size;
return buffer_size(bs_);
}())
{
@@ -502,7 +501,6 @@ prepare(std::size_t n) ->
end_ = out_;
if(end_ != net::buffer_sequence_end(bs_))
{
using net::buffer_size;
auto size = buffer_size(*end_) - out_pos_;
if(n > size)
{
@@ -545,7 +543,6 @@ commit(std::size_t n) noexcept
auto const last = std::prev(end_);
while(out_ != last)
{
using net::buffer_size;
auto const avail =
buffer_size(*out_) - out_pos_;
if(n < avail)
@@ -579,7 +576,6 @@ consume(std::size_t n) noexcept
{
while(begin_ != out_)
{
using net::buffer_size;
auto const avail =
buffer_size(*begin_) - in_pos_;
if(n < avail)
@@ -10,6 +10,7 @@
#ifndef 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 <algorithm>
#include <cstdint>
@@ -149,7 +150,6 @@ setup(std::size_t size)
auto const last = bs_.end();
while(end_ != last)
{
using net::buffer_size;
auto const len = buffer_size(*end_++);
if(len >= size)
{
@@ -248,14 +248,6 @@ end() const ->
*this, std::true_type{}};
}
template<class Buffers>
std::size_t
buffer_size(buffers_prefix_view<
Buffers> const& buffers)
{
return buffers.size_;
}
//------------------------------------------------------------------------------
template<>
@@ -290,14 +282,13 @@ public:
std::forward<Args>(args)...))
{
}
};
std::size_t
buffer_size(buffers_prefix_view<
net::const_buffer> const& buffers)
{
return buffers.size();
}
std::size_t
buffer_size_impl() const noexcept
{
return this->size();
}
};
//------------------------------------------------------------------------------
@@ -333,14 +324,13 @@ public:
std::forward<Args>(args)...))
{
}
};
std::size_t
buffer_size(buffers_prefix_view<
net::mutable_buffer> const& buffers)
{
return buffers.size();
}
std::size_t
buffer_size_impl() const noexcept
{
return this->size();
}
};
} // beast
} // boost
@@ -10,6 +10,7 @@
#ifndef 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/type_traits.hpp>
#include <algorithm>
@@ -206,7 +207,6 @@ consume(std::size_t amount)
net::buffer_sequence_end(bs_);
for(;amount > 0 && begin_ != end; ++begin_)
{
using net::buffer_size;
auto const len =
buffer_size(*begin_) - skip_;
if(amount < len)
@@ -10,6 +10,7 @@
#ifndef 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/config/workaround.hpp>
#include <boost/core/exchange.hpp>
@@ -195,11 +196,10 @@ public:
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
friend
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
{
#ifndef NDEBUG
using net::buffer_size;
BOOST_ASSERT(buffer_size(data()) == in_size_);
if(list_.empty())
{
+1 -1
View File
@@ -11,6 +11,7 @@
#define BOOST_BEAST_MAKE_PRINTABLE_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/asio/buffer.hpp>
#include <ostream>
@@ -73,7 +74,6 @@ operator<<(std::ostream& os,
void
print (ConstBufferSequence const& buffers)
{
using net::buffer_size;
std::cout <<
"Buffer size: " << buffer_size(buffers) << " bytes\n"
"Buffer data: '" << make_printable(buffers) << "'\n";
@@ -11,6 +11,7 @@
#define BOOST_BEAST_HTTP_BASIC_DYNAMIC_BODY_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/detail/buffer.hpp>
#include <boost/beast/http/error.hpp>
@@ -88,7 +89,6 @@ struct basic_dynamic_body
put(ConstBufferSequence const& buffers,
error_code& ec)
{
using net::buffer_size;
auto const n = buffer_size(buffers);
if(body_.size() > body_.max_size() - n)
{
+1 -1
View File
@@ -11,6 +11,7 @@
#define BOOST_BEAST_HTTP_BUFFER_BODY_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/message.hpp>
#include <boost/beast/http/type_traits.hpp>
@@ -132,7 +133,6 @@ struct buffer_body
body_.data = static_cast<char*>(
body_.data) + bytes_transferred;
body_.size -= bytes_transferred;
using net::buffer_size;
if(bytes_transferred == buffer_size(buffers))
ec = {};
else
@@ -10,6 +10,7 @@
#ifndef 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/type_traits.hpp>
#include <boost/beast/core/detail/clamp.hpp>
@@ -106,7 +107,6 @@ put(ConstBufferSequence const& buffers,
// single buffer
return put(net::const_buffer(*p), ec);
}
using net::buffer_size;
auto const size = buffer_size(buffers);
if(size <= max_stack_buffer)
return put_from_stack(size, buffers, ec);
@@ -130,7 +130,6 @@ put(net::const_buffer const& buffer,
error_code& ec)
{
BOOST_ASSERT(state_ != state::complete);
using net::buffer_size;
auto p = static_cast<char const*>(buffer.data());
auto n = buffer.size();
auto const p0 = p;
+5 -20
View File
@@ -10,6 +10,7 @@
#ifndef 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/http/error.hpp>
#include <boost/beast/http/detail/rfc7230.hpp>
@@ -89,11 +90,7 @@ template<class ConstBufferSequence>
chunk_body<ConstBufferSequence>::
chunk_body(ConstBufferSequence const& buffers)
: view_(
[&]
{
using net::buffer_size;
return buffer_size(buffers);
}(),
buffer_size(buffers),
net::const_buffer{nullptr, 0},
chunk_crlf{},
buffers,
@@ -107,11 +104,7 @@ chunk_body(
ConstBufferSequence const& buffers,
string_view extensions)
: view_(
[&]
{
using net::buffer_size;
return buffer_size(buffers);
}(),
buffer_size(buffers),
net::const_buffer{
extensions.data(), extensions.size()},
chunk_crlf{},
@@ -130,11 +123,7 @@ chunk_body(
typename std::decay<ChunkExtensions>::type>>(
std::forward<ChunkExtensions>(extensions)))
, view_(
[&]
{
using net::buffer_size;
return buffer_size(buffers);
}(),
buffer_size(buffers),
exts_->str(),
chunk_crlf{},
buffers,
@@ -153,11 +142,7 @@ chunk_body(
typename std::decay<ChunkExtensions>::type>>(allocator,
std::forward<ChunkExtensions>(extensions)))
, view_(
[&]
{
using net::buffer_size;
return buffer_size(buffers);
}(),
buffer_size(buffers),
exts_->str(),
chunk_crlf{},
buffers,
+1 -2
View File
@@ -10,6 +10,7 @@
#ifndef 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/http/error.hpp>
#include <boost/beast/http/status.hpp>
@@ -70,7 +71,6 @@ void
serializer<isRequest, Body, Fields>::
next(error_code& ec, Visit&& visit)
{
using net::buffer_size;
switch(s_)
{
case do_construct:
@@ -289,7 +289,6 @@ void
serializer<isRequest, Body, Fields>::
consume(std::size_t n)
{
using net::buffer_size;
switch(s_)
{
case do_header:
+1 -1
View File
@@ -11,6 +11,7 @@
#define BOOST_BEAST_HTTP_SPAN_BODY_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/span.hpp>
#include <boost/beast/http/error.hpp>
#include <boost/beast/http/message.hpp>
@@ -95,7 +96,6 @@ public:
put(ConstBufferSequence const& buffers,
error_code& ec)
{
using net::buffer_size;
auto const n = buffer_size(buffers);
auto const len = body_.size();
if(n > len)
+1 -1
View File
@@ -11,6 +11,7 @@
#define BOOST_BEAST_HTTP_STRING_BODY_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/message.hpp>
#include <boost/beast/core/buffers_range.hpp>
@@ -117,7 +118,6 @@ public:
put(ConstBufferSequence const& buffers,
error_code& ec)
{
using net::buffer_size;
auto const extra = buffer_size(buffers);
auto const size = body_.size();
try
+1 -1
View File
@@ -11,6 +11,7 @@
#define BOOST_BEAST_HTTP_VECTOR_BODY_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/message.hpp>
#include <boost/beast/core/detail/type_traits.hpp>
@@ -111,7 +112,6 @@ public:
put(ConstBufferSequence const& buffers,
error_code& ec)
{
using net::buffer_size;
auto const n = buffer_size(buffers);
auto const len = body_.size();
try
@@ -10,6 +10,7 @@
#ifndef 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/rfc6455.hpp>
#include <boost/beast/websocket/detail/utf8_checker.hpp>
@@ -229,7 +230,6 @@ template<class Buffers>
void
read_ping(ping_data& data, Buffers const& bs)
{
using net::buffer_size;
BOOST_ASSERT(buffer_size(bs) <= data.max_size());
data.resize(buffer_size(bs));
net::buffer_copy(net::mutable_buffer{
@@ -246,9 +246,7 @@ read_close(
Buffers const& bs,
error_code& ec)
{
using net::buffer;
using namespace boost::endian;
using net::buffer_size;
auto n = buffer_size(bs);
BOOST_ASSERT(n <= 125);
if(n == 0)
@@ -266,7 +264,7 @@ read_close(
buffers_suffix<Buffers> cb(bs);
{
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]);
cb.consume(2);
n -= 2;
@@ -280,7 +278,8 @@ read_close(
if(n > 0)
{
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(
cr.reason.data(), cr.reason.size()))
{
@@ -10,6 +10,7 @@
#ifndef 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/message.hpp>
#include <boost/beast/http/string_body.hpp>
@@ -88,7 +89,6 @@ struct impl_base<true>
std::size_t& total_in,
error_code& ec)
{
using net::buffer;
BOOST_ASSERT(out.size() >= 6);
auto& zo = this->pmd_->zo;
zlib::z_params zs;
@@ -123,7 +123,6 @@ struct impl_base<true>
cb.consume(zs.total_in);
if(zs.avail_out > 0 && fin)
{
using net::buffer_size;
auto const remain = buffer_size(cb);
if(remain == 0)
{
@@ -144,13 +143,13 @@ struct impl_base<true>
BOOST_ASSERT(! ec);
// remove flush marker
zs.total_out -= 4;
out = buffer(out.data(), zs.total_out);
out = net::buffer(out.data(), zs.total_out);
return false;
}
}
}
ec = {};
out = buffer(out.data(), zs.total_out);
out = net::buffer(out.data(), zs.total_out);
return true;
}
@@ -10,6 +10,7 @@
#ifndef 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/http/empty_body.hpp>
#include <boost/beast/http/parser.hpp>
@@ -122,7 +123,6 @@ public:
void run(Buffers const& buffers)
{
error_code ec;
using net::buffer_size;
auto const mb = beast::detail::dynamic_buffer_prepare(
ws_.impl_->rd_buf, buffer_size(buffers), ec,
error::buffer_overflow);
@@ -296,7 +296,6 @@ accept(
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
impl_->reset();
using net::buffer_size;
auto const mb = beast::detail::dynamic_buffer_prepare(
impl_->rd_buf, buffer_size(buffers), ec,
error::buffer_overflow);
@@ -327,7 +326,6 @@ accept_ex(
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
impl_->reset();
using net::buffer_size;
auto const mb = beast::detail::dynamic_buffer_prepare(
impl_->rd_buf, buffer_size(buffers), ec,
error::buffer_overflow);
+1 -4
View File
@@ -10,6 +10,7 @@
#ifndef 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/detail/mask.hpp>
#include <boost/beast/core/async_op_base.hpp>
@@ -82,8 +83,6 @@ public:
bool cont = true)
{
using beast::detail::clamp;
using net::buffer;
using net::buffer_size;
auto& impl = *ws_.impl_;
cont_ = cont;
BOOST_ASIO_CORO_REENTER(*this)
@@ -881,8 +880,6 @@ read_some(
MutableBufferSequence>::value,
"MutableBufferSequence requirements not met");
using beast::detail::clamp;
using net::buffer;
using net::buffer_size;
close_code code{};
std::size_t bytes_written = 0;
ec = {};
@@ -10,6 +10,7 @@
#ifndef 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/teardown.hpp>
#include <boost/beast/websocket/detail/hybi13.hpp>
@@ -282,7 +283,6 @@ parse_fh(
DynamicBuffer& b,
error_code& ec)
{
using net::buffer_size;
if(buffer_size(b.data()) < 2)
{
// need more bytes
@@ -57,7 +57,6 @@ public:
error_code ec = {},
std::size_t bytes_transferred = 0)
{
using net::buffer;
using tcp = net::ip::tcp;
BOOST_ASIO_CORO_REENTER(*this)
{
@@ -130,7 +129,6 @@ teardown(
net::ip::tcp::socket& socket,
error_code& ec)
{
using net::buffer;
if(role == role_type::server)
socket.shutdown(
net::ip::tcp::socket::shutdown_send, ec);
@@ -140,7 +138,7 @@ teardown(
{
char buf[2048];
auto const bytes_transferred =
socket.read_some(buffer(buf), ec);
socket.read_some(net::buffer(buf), ec);
if(ec)
{
if(ec != net::error::eof)
+1 -2
View File
@@ -13,6 +13,7 @@
#include <boost/beast/websocket/detail/mask.hpp>
#include <boost/beast/core/async_op_base.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_prefix.hpp>
#include <boost/beast/core/buffers_range.hpp>
@@ -88,7 +89,6 @@ operator()(
bool cont)
{
using beast::detail::clamp;
using net::buffer_size;
enum
{
do_nomask_nofrag,
@@ -470,7 +470,6 @@ write_some(bool fin,
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
using beast::detail::clamp;
using net::buffer_size;
std::size_t bytes_transferred = 0;
ec = {};
// Make sure the stream is open