mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
buffers_prefix replaces buffer_prefix (API Change)
fix #773 * buffer_prefix is renamed to buffers_prefix * buffer_prefix_view is renamed to buffers_prefix_view Actions Required: * Use buffers_prefix instead of buffer_prefix * Use buffers_prefix_view instead of buffer_prefix_view
This commit is contained in:
@ -3,10 +3,14 @@ Version 117:
|
||||
API Changes:
|
||||
|
||||
* buffers_suffix replaces consuming_buffers
|
||||
* buffers_prefix replaces buffer_prefix
|
||||
* buffers_prefix_view replaces buffer_prefix_view
|
||||
|
||||
Actions Required:
|
||||
|
||||
* Use buffers_suffix instead of consuming_buffers
|
||||
* Use buffers_prefix instead of buffer_prefix
|
||||
* Use buffers_prefix_view instead of buffer_prefix_view
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -129,17 +129,17 @@ transferred.
|
||||
or a buffer of size zero if the buffer sequence has no elements.
|
||||
]]
|
||||
[[
|
||||
[link beast.ref.boost__beast__buffer_prefix `buffer_prefix`]
|
||||
[link beast.ref.boost__beast__buffers_prefix `buffers_prefix`]
|
||||
][
|
||||
This function returns a new buffer or buffer sequence which represents
|
||||
a prefix of the original buffers.
|
||||
]]
|
||||
[[
|
||||
[link beast.ref.boost__beast__buffer_prefix_view `buffer_prefix_view`]
|
||||
[link beast.ref.boost__beast__buffers_prefix_view `buffers_prefix_view`]
|
||||
][
|
||||
This class represents the buffer sequence formed from a prefix of
|
||||
an existing buffer sequence. This is the type of buffer returned by
|
||||
[link beast.ref.boost__beast__buffer_prefix.overload3 `buffer_prefix`].
|
||||
[link beast.ref.boost__beast__buffers_prefix.overload3 `buffers_prefix`].
|
||||
]]
|
||||
[[
|
||||
[link beast.ref.boost__beast__buffers_suffix `buffers_suffix`]
|
||||
|
@ -180,9 +180,9 @@
|
||||
<member><link linkend="beast.ref.boost__beast__basic_flat_buffer">basic_flat_buffer</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__basic_multi_buffer">basic_multi_buffer</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__buffer_cat_view">buffer_cat_view</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__buffer_prefix_view">buffer_prefix_view</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__buffered_read_stream">buffered_read_stream</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__buffers_adapter">buffers_adapter</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__buffers_prefix_view">buffers_prefix_view</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__buffers_suffix">buffers_suffix</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__file">file</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__file_mode">file_mode</link></member>
|
||||
@ -217,8 +217,8 @@
|
||||
<member><link linkend="beast.ref.boost__beast__bind_handler">bind_handler</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__buffer_cat">buffer_cat</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__buffer_front">buffer_front</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__buffer_prefix">buffer_prefix</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__buffers">buffers</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__buffers_prefix">buffers_prefix</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__generic_category">generic_category</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__iequals">iequals</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__ostream">ostream</link></member>
|
||||
|
@ -199,9 +199,9 @@ operator()(boost::beast::error_code ec, std::size_t bytes_transferred)
|
||||
// write everything back
|
||||
p.step = 2;
|
||||
// async_read_until could have read past the newline,
|
||||
// use buffer_prefix to make sure we only send one line
|
||||
// use buffers_prefix to make sure we only send one line
|
||||
return boost::asio::async_write(p.stream,
|
||||
boost::beast::buffer_prefix(bytes_transferred, p.buffer.data()), std::move(*this));
|
||||
boost::beast::buffers_prefix(bytes_transferred, p.buffer.data()), std::move(*this));
|
||||
|
||||
case 2:
|
||||
p.buffer.consume(bytes_transferred);
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <boost/beast/core/async_result.hpp>
|
||||
#include <boost/beast/core/bind_handler.hpp>
|
||||
#include <boost/beast/core/buffer_cat.hpp>
|
||||
#include <boost/beast/core/buffer_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_prefix.hpp>
|
||||
#include <boost/beast/core/buffered_read_stream.hpp>
|
||||
#include <boost/beast/core/buffers_adapter.hpp>
|
||||
#include <boost/beast/core/buffers_suffix.hpp>
|
||||
|
@ -65,11 +65,11 @@ namespace beast {
|
||||
boost::asio::read_until(
|
||||
stream.next_layer(), stream.buffer(), "\r\n\r\n");
|
||||
|
||||
// Use buffer_prefix() to limit the input
|
||||
// Use buffers_prefix() to limit the input
|
||||
// sequence to only the data up to and including
|
||||
// the trailing "\r\n\r\n".
|
||||
//
|
||||
auto header_buffers = buffer_prefix(
|
||||
auto header_buffers = buffers_prefix(
|
||||
bytes_transferred, stream.buffer().data());
|
||||
|
||||
...
|
||||
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_BUFFER_PREFIX_HPP
|
||||
#define BOOST_BEAST_BUFFER_PREFIX_HPP
|
||||
#ifndef BOOST_BEAST_BUFFERS_PREFIX_HPP
|
||||
#define BOOST_BEAST_BUFFERS_PREFIX_HPP
|
||||
|
||||
#include <boost/beast/config.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
@ -29,7 +29,7 @@ namespace beast {
|
||||
@tparam BufferSequence The buffer sequence to adapt.
|
||||
*/
|
||||
template<class BufferSequence>
|
||||
class buffer_prefix_view
|
||||
class buffers_prefix_view
|
||||
{
|
||||
using buffers_type = typename
|
||||
std::decay<BufferSequence>::type;
|
||||
@ -42,7 +42,7 @@ class buffer_prefix_view
|
||||
iter_type end_;
|
||||
|
||||
template<class Deduced>
|
||||
buffer_prefix_view(
|
||||
buffers_prefix_view(
|
||||
Deduced&& other, std::size_t dist)
|
||||
: bs_(std::forward<Deduced>(other).bs_)
|
||||
, size_(other.size_)
|
||||
@ -72,16 +72,16 @@ public:
|
||||
#endif
|
||||
|
||||
/// Move constructor.
|
||||
buffer_prefix_view(buffer_prefix_view&&);
|
||||
buffers_prefix_view(buffers_prefix_view&&);
|
||||
|
||||
/// Copy constructor.
|
||||
buffer_prefix_view(buffer_prefix_view const&);
|
||||
buffers_prefix_view(buffers_prefix_view const&);
|
||||
|
||||
/// Move assignment.
|
||||
buffer_prefix_view& operator=(buffer_prefix_view&&);
|
||||
buffers_prefix_view& operator=(buffers_prefix_view&&);
|
||||
|
||||
/// Copy assignment.
|
||||
buffer_prefix_view& operator=(buffer_prefix_view const&);
|
||||
buffers_prefix_view& operator=(buffers_prefix_view const&);
|
||||
|
||||
/** Construct a buffer sequence prefix.
|
||||
|
||||
@ -94,7 +94,7 @@ public:
|
||||
the sequence will be made, but ownership of the underlying
|
||||
memory is not transferred.
|
||||
*/
|
||||
buffer_prefix_view(
|
||||
buffers_prefix_view(
|
||||
std::size_t size,
|
||||
BufferSequence const& buffers);
|
||||
|
||||
@ -108,7 +108,7 @@ public:
|
||||
@param args Arguments forwarded to the contained buffers constructor.
|
||||
*/
|
||||
template<class... Args>
|
||||
buffer_prefix_view(
|
||||
buffers_prefix_view(
|
||||
std::size_t size,
|
||||
boost::in_place_init_t,
|
||||
Args&&... args);
|
||||
@ -138,7 +138,7 @@ public:
|
||||
*/
|
||||
inline
|
||||
boost::asio::const_buffer
|
||||
buffer_prefix(std::size_t size,
|
||||
buffers_prefix(std::size_t size,
|
||||
boost::asio::const_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
@ -163,7 +163,7 @@ buffer_prefix(std::size_t size,
|
||||
*/
|
||||
inline
|
||||
boost::asio::mutable_buffer
|
||||
buffer_prefix(std::size_t size,
|
||||
buffers_prefix(std::size_t size,
|
||||
boost::asio::mutable_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
@ -190,7 +190,7 @@ buffer_prefix(std::size_t size,
|
||||
*/
|
||||
template<class BufferSequence>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
buffer_prefix_view<BufferSequence>
|
||||
buffers_prefix_view<BufferSequence>
|
||||
#else
|
||||
inline
|
||||
typename std::enable_if<
|
||||
@ -198,15 +198,15 @@ typename std::enable_if<
|
||||
boost::asio::const_buffer>::value &&
|
||||
! std::is_same<BufferSequence,
|
||||
boost::asio::mutable_buffer>::value,
|
||||
buffer_prefix_view<BufferSequence>>::type
|
||||
buffers_prefix_view<BufferSequence>>::type
|
||||
#endif
|
||||
buffer_prefix(std::size_t size, BufferSequence const& buffers)
|
||||
buffers_prefix(std::size_t size, BufferSequence const& buffers)
|
||||
{
|
||||
static_assert(
|
||||
is_const_buffer_sequence<BufferSequence>::value ||
|
||||
is_mutable_buffer_sequence<BufferSequence>::value,
|
||||
"BufferSequence requirements not met");
|
||||
return buffer_prefix_view<BufferSequence>(size, buffers);
|
||||
return buffers_prefix_view<BufferSequence>(size, buffers);
|
||||
}
|
||||
|
||||
/** Returns the first buffer in a buffer sequence
|
||||
@ -235,6 +235,6 @@ buffer_front(BufferSequence const& buffers)
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/buffer_prefix.ipp>
|
||||
#include <boost/beast/core/impl/buffers_prefix.ipp>
|
||||
|
||||
#endif
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_IMPL_BUFFER_PREFIX_IPP
|
||||
#define BOOST_BEAST_IMPL_BUFFER_PREFIX_IPP
|
||||
#ifndef BOOST_BEAST_IMPL_BUFFERS_PREFIX_IPP
|
||||
#define BOOST_BEAST_IMPL_BUFFERS_PREFIX_IPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
@ -24,7 +24,7 @@ namespace detail {
|
||||
|
||||
inline
|
||||
boost::asio::const_buffer
|
||||
buffer_prefix(std::size_t size,
|
||||
buffers_prefix(std::size_t size,
|
||||
boost::asio::const_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
@ -35,7 +35,7 @@ buffer_prefix(std::size_t size,
|
||||
|
||||
inline
|
||||
boost::asio::mutable_buffer
|
||||
buffer_prefix(std::size_t size,
|
||||
buffers_prefix(std::size_t size,
|
||||
boost::asio::mutable_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
@ -47,11 +47,11 @@ buffer_prefix(std::size_t size,
|
||||
} // detail
|
||||
|
||||
template<class BufferSequence>
|
||||
class buffer_prefix_view<BufferSequence>::const_iterator
|
||||
class buffers_prefix_view<BufferSequence>::const_iterator
|
||||
{
|
||||
friend class buffer_prefix_view<BufferSequence>;
|
||||
friend class buffers_prefix_view<BufferSequence>;
|
||||
|
||||
buffer_prefix_view const* b_ = nullptr;
|
||||
buffers_prefix_view const* b_ = nullptr;
|
||||
std::size_t remain_;
|
||||
iter_type it_;
|
||||
|
||||
@ -89,7 +89,7 @@ public:
|
||||
reference
|
||||
operator*() const
|
||||
{
|
||||
return detail::buffer_prefix(remain_, *it_);
|
||||
return detail::buffers_prefix(remain_, *it_);
|
||||
}
|
||||
|
||||
pointer
|
||||
@ -126,7 +126,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const_iterator(buffer_prefix_view const& b,
|
||||
const_iterator(buffers_prefix_view const& b,
|
||||
std::true_type)
|
||||
: b_(&b)
|
||||
, remain_(0)
|
||||
@ -134,7 +134,7 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
const_iterator(buffer_prefix_view const& b,
|
||||
const_iterator(buffers_prefix_view const& b,
|
||||
std::false_type)
|
||||
: b_(&b)
|
||||
, remain_(b_->size_)
|
||||
@ -145,7 +145,7 @@ private:
|
||||
|
||||
template<class BufferSequence>
|
||||
void
|
||||
buffer_prefix_view<BufferSequence>::
|
||||
buffers_prefix_view<BufferSequence>::
|
||||
setup(std::size_t size)
|
||||
{
|
||||
size_ = 0;
|
||||
@ -166,18 +166,18 @@ setup(std::size_t size)
|
||||
}
|
||||
|
||||
template<class BufferSequence>
|
||||
buffer_prefix_view<BufferSequence>::
|
||||
buffer_prefix_view(buffer_prefix_view&& other)
|
||||
: buffer_prefix_view(std::move(other),
|
||||
buffers_prefix_view<BufferSequence>::
|
||||
buffers_prefix_view(buffers_prefix_view&& other)
|
||||
: buffers_prefix_view(std::move(other),
|
||||
std::distance<iter_type>(
|
||||
other.bs_.begin(), other.end_))
|
||||
{
|
||||
}
|
||||
|
||||
template<class BufferSequence>
|
||||
buffer_prefix_view<BufferSequence>::
|
||||
buffer_prefix_view(buffer_prefix_view const& other)
|
||||
: buffer_prefix_view(other,
|
||||
buffers_prefix_view<BufferSequence>::
|
||||
buffers_prefix_view(buffers_prefix_view const& other)
|
||||
: buffers_prefix_view(other,
|
||||
std::distance<iter_type>(
|
||||
other.bs_.begin(), other.end_))
|
||||
{
|
||||
@ -185,9 +185,9 @@ buffer_prefix_view(buffer_prefix_view const& other)
|
||||
|
||||
template<class BufferSequence>
|
||||
auto
|
||||
buffer_prefix_view<BufferSequence>::
|
||||
operator=(buffer_prefix_view&& other) ->
|
||||
buffer_prefix_view&
|
||||
buffers_prefix_view<BufferSequence>::
|
||||
operator=(buffers_prefix_view&& other) ->
|
||||
buffers_prefix_view&
|
||||
{
|
||||
auto const dist = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.end_);
|
||||
@ -199,9 +199,9 @@ operator=(buffer_prefix_view&& other) ->
|
||||
|
||||
template<class BufferSequence>
|
||||
auto
|
||||
buffer_prefix_view<BufferSequence>::
|
||||
operator=(buffer_prefix_view const& other) ->
|
||||
buffer_prefix_view&
|
||||
buffers_prefix_view<BufferSequence>::
|
||||
operator=(buffers_prefix_view const& other) ->
|
||||
buffers_prefix_view&
|
||||
{
|
||||
auto const dist = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.end_);
|
||||
@ -212,8 +212,8 @@ operator=(buffer_prefix_view const& other) ->
|
||||
}
|
||||
|
||||
template<class BufferSequence>
|
||||
buffer_prefix_view<BufferSequence>::
|
||||
buffer_prefix_view(std::size_t size,
|
||||
buffers_prefix_view<BufferSequence>::
|
||||
buffers_prefix_view(std::size_t size,
|
||||
BufferSequence const& bs)
|
||||
: bs_(bs)
|
||||
{
|
||||
@ -222,8 +222,8 @@ buffer_prefix_view(std::size_t size,
|
||||
|
||||
template<class BufferSequence>
|
||||
template<class... Args>
|
||||
buffer_prefix_view<BufferSequence>::
|
||||
buffer_prefix_view(std::size_t size,
|
||||
buffers_prefix_view<BufferSequence>::
|
||||
buffers_prefix_view(std::size_t size,
|
||||
boost::in_place_init_t, Args&&... args)
|
||||
: bs_(std::forward<Args>(args)...)
|
||||
{
|
||||
@ -233,7 +233,7 @@ buffer_prefix_view(std::size_t size,
|
||||
template<class BufferSequence>
|
||||
inline
|
||||
auto
|
||||
buffer_prefix_view<BufferSequence>::begin() const ->
|
||||
buffers_prefix_view<BufferSequence>::begin() const ->
|
||||
const_iterator
|
||||
{
|
||||
return const_iterator{*this, std::false_type{}};
|
||||
@ -242,7 +242,7 @@ buffer_prefix_view<BufferSequence>::begin() const ->
|
||||
template<class BufferSequence>
|
||||
inline
|
||||
auto
|
||||
buffer_prefix_view<BufferSequence>::end() const ->
|
||||
buffers_prefix_view<BufferSequence>::end() const ->
|
||||
const_iterator
|
||||
{
|
||||
return const_iterator{*this, std::true_type{}};
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <boost/beast/config.hpp>
|
||||
#include <boost/beast/core/buffer_cat.hpp>
|
||||
#include <boost/beast/core/buffer_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_suffix.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
@ -118,16 +118,16 @@ private:
|
||||
|
||||
using cb1_t = buffers_suffix<typename
|
||||
Fields::reader::const_buffers_type>; // header
|
||||
using pcb1_t = buffer_prefix_view<cb1_t const&>;
|
||||
using pcb1_t = buffers_prefix_view<cb1_t const&>;
|
||||
|
||||
using cb2_t = buffers_suffix<buffer_cat_view<
|
||||
typename Fields::reader::const_buffers_type,// header
|
||||
typename reader::const_buffers_type>>; // body
|
||||
using pcb2_t = buffer_prefix_view<cb2_t const&>;
|
||||
using pcb2_t = buffers_prefix_view<cb2_t const&>;
|
||||
|
||||
using cb3_t = buffers_suffix<
|
||||
typename reader::const_buffers_type>; // body
|
||||
using pcb3_t = buffer_prefix_view<cb3_t const&>;
|
||||
using pcb3_t = buffers_prefix_view<cb3_t const&>;
|
||||
|
||||
using cb4_t = buffers_suffix<buffer_cat_view<
|
||||
typename Fields::reader::const_buffers_type,// header
|
||||
@ -136,7 +136,7 @@ private:
|
||||
chunk_crlf, // crlf
|
||||
typename reader::const_buffers_type, // body
|
||||
chunk_crlf>>; // crlf
|
||||
using pcb4_t = buffer_prefix_view<cb4_t const&>;
|
||||
using pcb4_t = buffers_prefix_view<cb4_t const&>;
|
||||
|
||||
using cb5_t = buffers_suffix<buffer_cat_view<
|
||||
detail::chunk_size, // chunk-header
|
||||
@ -144,7 +144,7 @@ private:
|
||||
chunk_crlf, // crlf
|
||||
typename reader::const_buffers_type, // body
|
||||
chunk_crlf>>; // crlf
|
||||
using pcb5_t = buffer_prefix_view<cb5_t const&>;
|
||||
using pcb5_t = buffers_prefix_view<cb5_t const&>;
|
||||
|
||||
using cb6_t = buffers_suffix<buffer_cat_view<
|
||||
detail::chunk_size, // chunk-header
|
||||
@ -155,7 +155,7 @@ private:
|
||||
boost::asio::const_buffers_1, // chunk-final
|
||||
boost::asio::const_buffers_1, // trailers
|
||||
chunk_crlf>>; // crlf
|
||||
using pcb6_t = buffer_prefix_view<cb6_t const&>;
|
||||
using pcb6_t = buffers_prefix_view<cb6_t const&>;
|
||||
|
||||
using cb7_t = buffers_suffix<buffer_cat_view<
|
||||
typename Fields::reader::const_buffers_type,// header
|
||||
@ -167,13 +167,13 @@ private:
|
||||
boost::asio::const_buffers_1, // chunk-final
|
||||
boost::asio::const_buffers_1, // trailers
|
||||
chunk_crlf>>; // crlf
|
||||
using pcb7_t = buffer_prefix_view<cb7_t const&>;
|
||||
using pcb7_t = buffers_prefix_view<cb7_t const&>;
|
||||
|
||||
using cb8_t = buffers_suffix<buffer_cat_view<
|
||||
boost::asio::const_buffers_1, // chunk-final
|
||||
boost::asio::const_buffers_1, // trailers
|
||||
chunk_crlf>>; // crlf
|
||||
using pcb8_t = buffer_prefix_view<cb8_t const&>;
|
||||
using pcb8_t = buffers_prefix_view<cb8_t const&>;
|
||||
|
||||
value_type& m_;
|
||||
reader rd_;
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <boost/beast/http/read.hpp>
|
||||
#include <boost/beast/http/string_body.hpp>
|
||||
#include <boost/beast/http/write.hpp>
|
||||
#include <boost/beast/core/buffer_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_prefix.hpp>
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/coroutine.hpp>
|
||||
|
@ -247,7 +247,7 @@ operator()(
|
||||
{
|
||||
BOOST_ASSERT(! d.ws.rd_close_);
|
||||
d.ws.rd_close_ = true;
|
||||
auto const mb = buffer_prefix(
|
||||
auto const mb = buffers_prefix(
|
||||
clamp(d.ws.rd_fh_.len),
|
||||
d.ws.rd_buf_.data());
|
||||
if(d.ws.rd_fh_.len > 0 && d.ws.rd_fh_.mask)
|
||||
@ -395,7 +395,7 @@ close(close_reason const& cr, error_code& ec)
|
||||
{
|
||||
BOOST_ASSERT(! rd_close_);
|
||||
rd_close_ = true;
|
||||
auto const mb = buffer_prefix(
|
||||
auto const mb = buffers_prefix(
|
||||
clamp(rd_fh_.len),
|
||||
rd_buf_.data());
|
||||
if(rd_fh_.len > 0 && rd_fh_.mask)
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <boost/beast/websocket/teardown.hpp>
|
||||
#include <boost/beast/core/bind_handler.hpp>
|
||||
#include <boost/beast/core/buffer_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_suffix.hpp>
|
||||
#include <boost/beast/core/flat_static_buffer.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
@ -228,7 +228,7 @@ operator()(
|
||||
// Immediately apply the mask to the portion
|
||||
// of the buffer holding payload data.
|
||||
if(ws_.rd_fh_.len > 0 && ws_.rd_fh_.mask)
|
||||
detail::mask_inplace(buffer_prefix(
|
||||
detail::mask_inplace(buffers_prefix(
|
||||
clamp(ws_.rd_fh_.len),
|
||||
ws_.rd_buf_.data()),
|
||||
ws_.rd_key_);
|
||||
@ -242,7 +242,7 @@ operator()(
|
||||
if(ws_.rd_fh_.op == detail::opcode::ping)
|
||||
{
|
||||
{
|
||||
auto const b = buffer_prefix(
|
||||
auto const b = buffers_prefix(
|
||||
clamp(ws_.rd_fh_.len),
|
||||
ws_.rd_buf_.data());
|
||||
auto const len = buffer_size(b);
|
||||
@ -313,7 +313,7 @@ operator()(
|
||||
// Handle pong frame
|
||||
if(ws_.rd_fh_.op == detail::opcode::pong)
|
||||
{
|
||||
auto const cb = buffer_prefix(clamp(
|
||||
auto const cb = buffers_prefix(clamp(
|
||||
ws_.rd_fh_.len), ws_.rd_buf_.data());
|
||||
auto const len = buffer_size(cb);
|
||||
BOOST_ASSERT(len == ws_.rd_fh_.len);
|
||||
@ -329,7 +329,7 @@ operator()(
|
||||
// Handle close frame
|
||||
BOOST_ASSERT(ws_.rd_fh_.op == detail::opcode::close);
|
||||
{
|
||||
auto const cb = buffer_prefix(clamp(
|
||||
auto const cb = buffers_prefix(clamp(
|
||||
ws_.rd_fh_.len), ws_.rd_buf_.data());
|
||||
auto const len = buffer_size(cb);
|
||||
BOOST_ASSERT(len == ws_.rd_fh_.len);
|
||||
@ -392,7 +392,7 @@ operator()(
|
||||
goto upcall;
|
||||
ws_.rd_buf_.commit(bytes_transferred);
|
||||
if(ws_.rd_fh_.mask)
|
||||
detail::mask_inplace(buffer_prefix(clamp(
|
||||
detail::mask_inplace(buffers_prefix(clamp(
|
||||
ws_.rd_remain_), ws_.rd_buf_.data()),
|
||||
ws_.rd_key_);
|
||||
}
|
||||
@ -402,7 +402,7 @@ operator()(
|
||||
// The mask was already applied.
|
||||
bytes_transferred = buffer_copy(cb_,
|
||||
ws_.rd_buf_.data(), clamp(ws_.rd_remain_));
|
||||
auto const mb = buffer_prefix(
|
||||
auto const mb = buffers_prefix(
|
||||
bytes_transferred, cb_);
|
||||
ws_.rd_remain_ -= bytes_transferred;
|
||||
if(ws_.rd_op_ == detail::opcode::text)
|
||||
@ -427,12 +427,12 @@ operator()(
|
||||
BOOST_ASSERT(ws_.rd_remain_ > 0);
|
||||
BOOST_ASSERT(buffer_size(cb_) > 0);
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
ws_.stream_.async_read_some(buffer_prefix(
|
||||
ws_.stream_.async_read_some(buffers_prefix(
|
||||
clamp(ws_.rd_remain_), cb_), std::move(*this));
|
||||
if(! ws_.check_ok(ec))
|
||||
goto upcall;
|
||||
BOOST_ASSERT(bytes_transferred > 0);
|
||||
auto const mb = buffer_prefix(
|
||||
auto const mb = buffers_prefix(
|
||||
bytes_transferred, cb_);
|
||||
ws_.rd_remain_ -= bytes_transferred;
|
||||
if(ws_.rd_fh_.mask)
|
||||
@ -478,7 +478,7 @@ operator()(
|
||||
ws_.rd_buf_.commit(bytes_transferred);
|
||||
if(ws_.rd_fh_.mask)
|
||||
detail::mask_inplace(
|
||||
buffer_prefix(clamp(ws_.rd_remain_),
|
||||
buffers_prefix(clamp(ws_.rd_remain_),
|
||||
ws_.rd_buf_.data()), ws_.rd_key_);
|
||||
did_read_ = true;
|
||||
}
|
||||
@ -494,7 +494,7 @@ operator()(
|
||||
if(ws_.rd_buf_.size() > 0)
|
||||
{
|
||||
// use what's there
|
||||
auto const in = buffer_prefix(
|
||||
auto const in = buffers_prefix(
|
||||
clamp(ws_.rd_remain_), buffer_front(
|
||||
ws_.rd_buf_.data()));
|
||||
zs.avail_in = buffer_size(in);
|
||||
@ -556,7 +556,7 @@ operator()(
|
||||
{
|
||||
// check utf8
|
||||
if(! ws_.rd_utf8_.write(
|
||||
buffer_prefix(bytes_written_, cb_.get())) || (
|
||||
buffers_prefix(bytes_written_, cb_.get())) || (
|
||||
ws_.rd_done_ && ! ws_.rd_utf8_.finish()))
|
||||
{
|
||||
// _Fail the WebSocket Connection_
|
||||
@ -1006,13 +1006,13 @@ loop:
|
||||
// Immediately apply the mask to the portion
|
||||
// of the buffer holding payload data.
|
||||
if(rd_fh_.len > 0 && rd_fh_.mask)
|
||||
detail::mask_inplace(buffer_prefix(
|
||||
detail::mask_inplace(buffers_prefix(
|
||||
clamp(rd_fh_.len), rd_buf_.data()),
|
||||
rd_key_);
|
||||
if(detail::is_control(rd_fh_.op))
|
||||
{
|
||||
// Get control frame payload
|
||||
auto const b = buffer_prefix(
|
||||
auto const b = buffers_prefix(
|
||||
clamp(rd_fh_.len), rd_buf_.data());
|
||||
auto const len = buffer_size(b);
|
||||
BOOST_ASSERT(len == rd_fh_.len);
|
||||
@ -1106,7 +1106,7 @@ loop:
|
||||
return bytes_written;
|
||||
if(rd_fh_.mask)
|
||||
detail::mask_inplace(
|
||||
buffer_prefix(clamp(rd_remain_),
|
||||
buffers_prefix(clamp(rd_remain_),
|
||||
rd_buf_.data()), rd_key_);
|
||||
}
|
||||
if(rd_buf_.size() > 0)
|
||||
@ -1116,7 +1116,7 @@ loop:
|
||||
auto const bytes_transferred =
|
||||
buffer_copy(buffers, rd_buf_.data(),
|
||||
clamp(rd_remain_));
|
||||
auto const mb = buffer_prefix(
|
||||
auto const mb = buffers_prefix(
|
||||
bytes_transferred, buffers);
|
||||
rd_remain_ -= bytes_transferred;
|
||||
if(rd_op_ == detail::opcode::text)
|
||||
@ -1143,12 +1143,12 @@ loop:
|
||||
BOOST_ASSERT(rd_remain_ > 0);
|
||||
BOOST_ASSERT(buffer_size(buffers) > 0);
|
||||
auto const bytes_transferred =
|
||||
stream_.read_some(buffer_prefix(
|
||||
stream_.read_some(buffers_prefix(
|
||||
clamp(rd_remain_), buffers), ec);
|
||||
if(! check_ok(ec))
|
||||
return bytes_written;
|
||||
BOOST_ASSERT(bytes_transferred > 0);
|
||||
auto const mb = buffer_prefix(
|
||||
auto const mb = buffers_prefix(
|
||||
bytes_transferred, buffers);
|
||||
rd_remain_ -= bytes_transferred;
|
||||
if(rd_fh_.mask)
|
||||
@ -1193,7 +1193,7 @@ loop:
|
||||
if(rd_buf_.size() > 0)
|
||||
{
|
||||
// use what's there
|
||||
auto const in = buffer_prefix(
|
||||
auto const in = buffers_prefix(
|
||||
clamp(rd_remain_), buffer_front(
|
||||
rd_buf_.data()));
|
||||
zs.avail_in = buffer_size(in);
|
||||
@ -1213,9 +1213,9 @@ loop:
|
||||
rd_buf_.commit(bytes_transferred);
|
||||
if(rd_fh_.mask)
|
||||
detail::mask_inplace(
|
||||
buffer_prefix(clamp(rd_remain_),
|
||||
buffers_prefix(clamp(rd_remain_),
|
||||
rd_buf_.data()), rd_key_);
|
||||
auto const in = buffer_prefix(
|
||||
auto const in = buffers_prefix(
|
||||
clamp(rd_remain_), buffer_front(
|
||||
rd_buf_.data()));
|
||||
zs.avail_in = buffer_size(in);
|
||||
@ -1277,7 +1277,7 @@ loop:
|
||||
{
|
||||
// check utf8
|
||||
if(! rd_utf8_.write(
|
||||
buffer_prefix(bytes_written, buffers)) || (
|
||||
buffers_prefix(bytes_written, buffers)) || (
|
||||
rd_done_ && ! rd_utf8_.finish()))
|
||||
{
|
||||
// _Fail the WebSocket Connection_
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <boost/beast/http/write.hpp>
|
||||
#include <boost/beast/http/rfc7230.hpp>
|
||||
#include <boost/beast/core/buffer_cat.hpp>
|
||||
#include <boost/beast/core/buffer_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_suffix.hpp>
|
||||
#include <boost/beast/core/flat_static_buffer.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <boost/beast/core/bind_handler.hpp>
|
||||
#include <boost/beast/core/buffer_cat.hpp>
|
||||
#include <boost/beast/core/buffer_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_suffix.hpp>
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
#include <boost/beast/core/flat_static_buffer.hpp>
|
||||
@ -272,7 +272,7 @@ operator()(
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
boost::asio::async_write(
|
||||
ws_.stream_, buffer_cat(
|
||||
ws_.wr_fb_.data(), buffer_prefix(
|
||||
ws_.wr_fb_.data(), buffers_prefix(
|
||||
clamp(fh_.len), cb_)),
|
||||
std::move(*this));
|
||||
if(! ws_.check_ok(ec))
|
||||
@ -630,7 +630,7 @@ write_some(bool fin,
|
||||
wr_cont_ = ! fin;
|
||||
boost::asio::write(stream_,
|
||||
buffer_cat(fh_buf.data(),
|
||||
buffer_prefix(n, cb)), ec);
|
||||
buffers_prefix(n, cb)), ec);
|
||||
if(! check_ok(ec))
|
||||
return bytes_transferred;
|
||||
bytes_transferred += n;
|
||||
|
@ -21,9 +21,9 @@ add_executable (tests-beast-core
|
||||
async_result.cpp
|
||||
bind_handler.cpp
|
||||
buffer_cat.cpp
|
||||
buffer_prefix.cpp
|
||||
buffered_read_stream.cpp
|
||||
buffers_adapter.cpp
|
||||
buffers_prefix.cpp
|
||||
buffers_suffix.cpp
|
||||
error.cpp
|
||||
file.cpp
|
||||
|
@ -11,9 +11,9 @@ local SOURCES =
|
||||
async_result.cpp
|
||||
bind_handler.cpp
|
||||
buffer_cat.cpp
|
||||
buffer_prefix.cpp
|
||||
buffered_read_stream.cpp
|
||||
buffers_adapter.cpp
|
||||
buffers_prefix.cpp
|
||||
buffers_suffix.cpp
|
||||
error.cpp
|
||||
file.cpp
|
||||
|
@ -8,7 +8,7 @@
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <boost/beast/core/buffer_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_prefix.hpp>
|
||||
|
||||
#include <boost/beast/core/buffers_suffix.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
@ -21,24 +21,24 @@ namespace beast {
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
std::is_same<boost::asio::const_buffer, decltype(
|
||||
buffer_prefix(0,
|
||||
buffers_prefix(0,
|
||||
std::declval<boost::asio::const_buffer>()))>::value);
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
is_const_buffer_sequence<decltype(
|
||||
buffer_prefix(0,
|
||||
buffers_prefix(0,
|
||||
std::declval<boost::asio::const_buffers_1>()))>::value);
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
std::is_same<boost::asio::mutable_buffer, decltype(
|
||||
buffer_prefix(0,
|
||||
buffers_prefix(0,
|
||||
std::declval<boost::asio::mutable_buffer>()))>::value);
|
||||
BOOST_STATIC_ASSERT(
|
||||
is_mutable_buffer_sequence<decltype(
|
||||
buffer_prefix(0,
|
||||
buffers_prefix(0,
|
||||
std::declval<boost::asio::mutable_buffers_1>()))>::value);
|
||||
|
||||
class buffer_prefix_test : public beast::unit_test::suite
|
||||
class buffers_prefix_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
template<class ConstBufferSequence>
|
||||
@ -123,14 +123,14 @@ public:
|
||||
BufferType{&s[x+y], z}}};
|
||||
for(std::size_t i = 0; i <= s.size() + 1; ++i)
|
||||
{
|
||||
auto pb = buffer_prefix(i, bs);
|
||||
auto pb = buffers_prefix(i, bs);
|
||||
BEAST_EXPECT(to_string(pb) == s.substr(0, i));
|
||||
auto pb2 = pb;
|
||||
BEAST_EXPECT(to_string(pb2) == to_string(pb));
|
||||
pb = buffer_prefix(0, bs);
|
||||
pb = buffers_prefix(0, bs);
|
||||
pb2 = pb;
|
||||
BEAST_EXPECT(buffer_size(pb2) == 0);
|
||||
pb2 = buffer_prefix(i, bs);
|
||||
pb2 = buffers_prefix(i, bs);
|
||||
BEAST_EXPECT(to_string(pb2) == s.substr(0, i));
|
||||
}
|
||||
}
|
||||
@ -142,9 +142,9 @@ public:
|
||||
using boost::asio::buffer_copy;
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::null_buffers;
|
||||
auto pb0 = buffer_prefix(0, null_buffers{});
|
||||
auto pb0 = buffers_prefix(0, null_buffers{});
|
||||
BEAST_EXPECT(buffer_size(pb0) == 0);
|
||||
auto pb1 = buffer_prefix(1, null_buffers{});
|
||||
auto pb1 = buffers_prefix(1, null_buffers{});
|
||||
BEAST_EXPECT(buffer_size(pb1) == 0);
|
||||
BEAST_EXPECT(buffer_copy(pb0, pb1) == 0);
|
||||
|
||||
@ -156,7 +156,7 @@ public:
|
||||
BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
BEAST_EXPECT(buffer_copy(cb, pb1) == 0);
|
||||
|
||||
auto pbc = buffer_prefix(2, cb);
|
||||
auto pbc = buffers_prefix(2, cb);
|
||||
BEAST_EXPECT(buffer_size(pbc) == 0);
|
||||
BEAST_EXPECT(buffer_copy(pbc, cb) == 0);
|
||||
}
|
||||
@ -170,7 +170,7 @@ public:
|
||||
const_buffer{&b[0], 1},
|
||||
const_buffer{&b[1], 1},
|
||||
const_buffer{&b[2], 1}}};
|
||||
auto pb = buffer_prefix(2, bs);
|
||||
auto pb = buffers_prefix(2, bs);
|
||||
BEAST_EXPECT(bsize1(pb) == 2);
|
||||
BEAST_EXPECT(bsize2(pb) == 2);
|
||||
BEAST_EXPECT(bsize3(pb) == 2);
|
||||
@ -186,7 +186,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(beast,core,buffer_prefix);
|
||||
BEAST_DEFINE_TESTSUITE(beast,core,buffers_prefix);
|
||||
|
||||
} // beast
|
||||
} // boost
|
@ -14,7 +14,7 @@
|
||||
#include "test_parser.hpp"
|
||||
|
||||
#include <boost/beast/core/buffer_cat.hpp>
|
||||
#include <boost/beast/core/buffer_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_suffix.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
@ -164,7 +164,7 @@ public:
|
||||
p.skip(skip);
|
||||
error_code ec;
|
||||
buffers_suffix<ConstBufferSequence> cb{buffers};
|
||||
auto n = p.put(buffer_prefix(i, cb), ec);
|
||||
auto n = p.put(buffers_prefix(i, cb), ec);
|
||||
if(! BEAST_EXPECTS(! ec ||
|
||||
ec == error::need_more, ec.message()))
|
||||
continue;
|
||||
@ -194,7 +194,7 @@ public:
|
||||
buffers_suffix<ConstBufferSequence> cb{buffers};
|
||||
cb.consume(i);
|
||||
auto n = p.put(buffer_cat(
|
||||
buffer_prefix(i, buffers), cb), ec);
|
||||
buffers_prefix(i, buffers), cb), ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
continue;
|
||||
if(! BEAST_EXPECT(n == size))
|
||||
@ -243,7 +243,7 @@ public:
|
||||
error_code ec;
|
||||
buffers_suffix<boost::asio::const_buffers_1> cb{
|
||||
boost::in_place_init, msg.data(), msg.size()};
|
||||
auto n = p.put(buffer_prefix(i, cb), ec);
|
||||
auto n = p.put(buffers_prefix(i, cb), ec);
|
||||
if(ec == result)
|
||||
{
|
||||
pass();
|
||||
|
@ -172,7 +172,7 @@ private:
|
||||
std::geometric_distribution<std::size_t> dist{
|
||||
double(4) / boost::asio::buffer_size(tb_)};
|
||||
ws_.async_write_some(true,
|
||||
boost::beast::buffer_prefix(dist(rng_), tb_),
|
||||
boost::beast::buffers_prefix(dist(rng_), tb_),
|
||||
alloc_.wrap(std::bind(
|
||||
&connection::on_write,
|
||||
shared_from_this(),
|
||||
|
@ -174,7 +174,7 @@ boost::asio::ip::tcp::socket sock{ios};
|
||||
using boost::asio::buffer_size;
|
||||
if(buffer_size(cb) > 512)
|
||||
{
|
||||
ws.write_some(false, buffer_prefix(512, cb));
|
||||
ws.write_some(false, buffers_prefix(512, cb));
|
||||
cb.consume(512);
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user