mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
Rename prepare_buffer(s) to buffer_prefix (API Change)
This commit is contained in:
@ -14,7 +14,7 @@ API Changes
|
||||
* Return http::error::end_of_stream on HTTP read eof
|
||||
* Remove placeholders
|
||||
* Move prepare_buffers to prepare_buffer.hpp
|
||||
* Replace asynchronous helper macros with template aliases
|
||||
* Rename prepare_buffer(s) to buffer_prefix
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -189,12 +189,11 @@ underlying memory, whose lifetime is retained by the caller.
|
||||
increments of a buffer sequence.
|
||||
]]
|
||||
[[
|
||||
[link beast.ref.prepare_buffer `prepare_buffer`]
|
||||
[link beast.ref.prepare_buffers `prepare_buffers`]
|
||||
[link beast.ref.buffer_prefix `buffer_prefix`]
|
||||
][
|
||||
These functions return a new buffer sequence which wraps the underlying
|
||||
memory of an existing buffer sequence, but with a smaller size. This
|
||||
lets callers work with a prefix of a buffer sequence.
|
||||
This function returns a new buffer or buffer sequence which wraps the
|
||||
underlying memory of an existing buffer sequence, but with a smaller size.
|
||||
This lets callers work with a prefix of a buffer sequence.
|
||||
]]
|
||||
]
|
||||
|
||||
|
@ -179,10 +179,9 @@
|
||||
<simplelist type="vert" columns="1">
|
||||
<member><link linkend="beast.ref.bind_handler">bind_handler</link></member>
|
||||
<member><link linkend="beast.ref.buffer_cat">buffer_cat</link></member>
|
||||
<member><link linkend="beast.ref.buffer_prefix">buffer_prefix</link></member>
|
||||
<member><link linkend="beast.ref.buffers">buffers</link></member>
|
||||
<member><link linkend="beast.ref.ostream">ostream</link></member>
|
||||
<member><link linkend="beast.ref.prepare_buffer">prepare_buffer</link></member>
|
||||
<member><link linkend="beast.ref.prepare_buffers">prepare_buffers</link></member>
|
||||
<member><link linkend="beast.ref.system_category">system_category</link></member>
|
||||
<member><link linkend="beast.ref.to_static_string">to_static_string</link></member>
|
||||
</simplelist>
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
#include <beast/core/async_result.hpp>
|
||||
#include <beast/core/bind_handler.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/core/prepare_buffer.hpp>
|
||||
#include <beast/websocket/teardown.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
@ -69,7 +69,7 @@ public:
|
||||
error_code& ec)
|
||||
{
|
||||
auto const n = boost::asio::buffer_copy(
|
||||
buffers, prepare_buffer(read_max_, cb_));
|
||||
buffers, buffer_prefix(read_max_, cb_));
|
||||
if(n > 0)
|
||||
cb_ = cb_ + n;
|
||||
else
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
#include <beast/core/async_result.hpp>
|
||||
#include <beast/core/bind_handler.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/core/prepare_buffer.hpp>
|
||||
#include <beast/websocket/teardown.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
@ -67,7 +67,7 @@ public:
|
||||
error_code& ec)
|
||||
{
|
||||
auto const n = boost::asio::buffer_copy(
|
||||
buffers, prepare_buffer(read_max_, cb_));
|
||||
buffers, buffer_prefix(read_max_, cb_));
|
||||
if(n > 0)
|
||||
cb_ = cb_ + n;
|
||||
else
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <beast/core/async_result.hpp>
|
||||
#include <beast/core/bind_handler.hpp>
|
||||
#include <beast/core/buffer_cat.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/buffers_adapter.hpp>
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/buffered_read_stream.hpp>
|
||||
@ -23,7 +24,6 @@
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/prepare_buffer.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/static_string.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
|
@ -5,22 +5,19 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BEAST_PREPARE_BUFFER_HPP
|
||||
#define BEAST_PREPARE_BUFFER_HPP
|
||||
#ifndef BEAST_BUFFER_PREFIX_HPP
|
||||
#define BEAST_BUFFER_PREFIX_HPP
|
||||
|
||||
#include <beast/config.hpp>
|
||||
#include <beast/core/detail/prepare_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/buffer_prefix.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace beast {
|
||||
|
||||
/** Return a shortened buffer.
|
||||
/** Returns a prefix of a constant buffer sequence.
|
||||
|
||||
The returned buffer points to the same memory as the
|
||||
passed buffer, but with a size that is equal to or less
|
||||
@ -36,7 +33,7 @@ namespace beast {
|
||||
*/
|
||||
inline
|
||||
boost::asio::const_buffer
|
||||
prepare_buffer(std::size_t n,
|
||||
buffer_prefix(std::size_t n,
|
||||
boost::asio::const_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
@ -45,7 +42,7 @@ prepare_buffer(std::size_t n,
|
||||
(std::min)(n, buffer_size(buffer)) };
|
||||
}
|
||||
|
||||
/** Return a shortened buffer.
|
||||
/** Returns a prefix of a mutable buffer sequence.
|
||||
|
||||
The returned buffer points to the same memory as the
|
||||
passed buffer, but with a size that is equal to or less
|
||||
@ -61,7 +58,7 @@ prepare_buffer(std::size_t n,
|
||||
*/
|
||||
inline
|
||||
boost::asio::mutable_buffer
|
||||
prepare_buffer(std::size_t n,
|
||||
buffer_prefix(std::size_t n,
|
||||
boost::asio::mutable_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
@ -70,32 +67,38 @@ prepare_buffer(std::size_t n,
|
||||
(std::min)(n, buffer_size(buffer)) };
|
||||
}
|
||||
|
||||
/** Return a shortened buffer sequence.
|
||||
/** Returns a prefix of a buffer sequence.
|
||||
|
||||
This function returns a new buffer sequence which adapts the
|
||||
passed buffer sequence and efficiently presents a shorter subset
|
||||
of the original list of buffers starting with the first byte of
|
||||
the original sequence.
|
||||
This function returns a new buffer sequence which when iterated,
|
||||
presents a shorter subset of the original list of buffers starting
|
||||
with the first byte of the original sequence.
|
||||
|
||||
@param n The maximum number of bytes in the wrapped
|
||||
sequence. If this is larger than the size of passed,
|
||||
buffers, the resulting sequence will represent the
|
||||
entire input sequence.
|
||||
|
||||
@param buffers The buffer sequence to adapt. A copy of
|
||||
the sequence will be made, but ownership of the underlying
|
||||
memory is not transferred.
|
||||
@param buffers An instance of @b ConstBufferSequence or
|
||||
@MutableBufferSequence to adapt. A copy of the sequence
|
||||
will be made, but ownership of the underlying memory is
|
||||
not transferred.
|
||||
*/
|
||||
template<class BufferSequence>
|
||||
#if BEAST_DOXYGEN
|
||||
implementation_defined
|
||||
#else
|
||||
inline
|
||||
detail::prepare_buffers_helper<BufferSequence>
|
||||
typename std::enable_if<
|
||||
! std::is_convertible<BufferSequence, boost::asio::const_buffer>::value,
|
||||
detail::buffer_prefix_helper<BufferSequence>>::type
|
||||
#endif
|
||||
prepare_buffers(std::size_t n, BufferSequence const& buffers)
|
||||
buffer_prefix(std::size_t n, BufferSequence const& buffers)
|
||||
{
|
||||
return detail::prepare_buffers_helper<BufferSequence>(n, buffers);
|
||||
static_assert(
|
||||
is_const_buffer_sequence<BufferSequence>::value ||
|
||||
is_mutable_buffer_sequence<BufferSequence>::value,
|
||||
"BufferSequence requirements not met");
|
||||
return detail::buffer_prefix_helper<BufferSequence>(n, buffers);
|
||||
}
|
||||
|
||||
} // beast
|
@ -62,11 +62,11 @@ namespace beast {
|
||||
boost::asio::read_until(
|
||||
stream.next_layer(), stream.buffer(), "\r\n\r\n");
|
||||
|
||||
// Use prepare_buffers() to limit the input
|
||||
// Use buffer_prefix() to limit the input
|
||||
// sequence to only the data up to and including
|
||||
// the trailing "\r\n\r\n".
|
||||
//
|
||||
auto header_buffers = prepare_buffers(
|
||||
auto header_buffers = buffer_prefix(
|
||||
bytes_transferred, stream.buffer().data());
|
||||
|
||||
...
|
||||
|
@ -21,7 +21,7 @@ namespace detail {
|
||||
|
||||
inline
|
||||
boost::asio::const_buffer
|
||||
prepare_buffer(std::size_t n,
|
||||
buffer_prefix(std::size_t n,
|
||||
boost::asio::const_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
@ -32,7 +32,7 @@ prepare_buffer(std::size_t n,
|
||||
|
||||
inline
|
||||
boost::asio::mutable_buffer
|
||||
prepare_buffer(std::size_t n,
|
||||
buffer_prefix(std::size_t n,
|
||||
boost::asio::mutable_buffer buffer)
|
||||
{
|
||||
using boost::asio::buffer_cast;
|
||||
@ -50,7 +50,7 @@ prepare_buffer(std::size_t n,
|
||||
@tparam BufferSequence The buffer sequence to adapt.
|
||||
*/
|
||||
template<class BufferSequence>
|
||||
class prepare_buffers_helper
|
||||
class buffer_prefix_helper
|
||||
{
|
||||
using iter_type =
|
||||
typename BufferSequence::const_iterator;
|
||||
@ -61,7 +61,7 @@ class prepare_buffers_helper
|
||||
std::size_t size_;
|
||||
|
||||
template<class Deduced>
|
||||
prepare_buffers_helper(Deduced&& other,
|
||||
buffer_prefix_helper(Deduced&& other,
|
||||
std::size_t nback, std::size_t nend)
|
||||
: bs_(std::forward<Deduced>(other).bs_)
|
||||
, back_(std::next(bs_.begin(), nback))
|
||||
@ -92,16 +92,16 @@ public:
|
||||
#endif
|
||||
|
||||
/// Move constructor.
|
||||
prepare_buffers_helper(prepare_buffers_helper&&);
|
||||
buffer_prefix_helper(buffer_prefix_helper&&);
|
||||
|
||||
/// Copy constructor.
|
||||
prepare_buffers_helper(prepare_buffers_helper const&);
|
||||
buffer_prefix_helper(buffer_prefix_helper const&);
|
||||
|
||||
/// Move assignment.
|
||||
prepare_buffers_helper& operator=(prepare_buffers_helper&&);
|
||||
buffer_prefix_helper& operator=(buffer_prefix_helper&&);
|
||||
|
||||
/// Copy assignment.
|
||||
prepare_buffers_helper& operator=(prepare_buffers_helper const&);
|
||||
buffer_prefix_helper& operator=(buffer_prefix_helper const&);
|
||||
|
||||
/** Construct a shortened buffer sequence.
|
||||
|
||||
@ -114,7 +114,7 @@ public:
|
||||
the sequence will be made, but ownership of the underlying
|
||||
memory is not transferred.
|
||||
*/
|
||||
prepare_buffers_helper(std::size_t n, BufferSequence const& buffers);
|
||||
buffer_prefix_helper(std::size_t n, BufferSequence const& buffers);
|
||||
|
||||
/// Get a bidirectional iterator to the first element.
|
||||
const_iterator
|
||||
@ -126,14 +126,14 @@ public:
|
||||
};
|
||||
|
||||
template<class BufferSequence>
|
||||
class prepare_buffers_helper<BufferSequence>::const_iterator
|
||||
class buffer_prefix_helper<BufferSequence>::const_iterator
|
||||
{
|
||||
friend class prepare_buffers_helper<BufferSequence>;
|
||||
friend class buffer_prefix_helper<BufferSequence>;
|
||||
|
||||
using iter_type =
|
||||
typename BufferSequence::const_iterator;
|
||||
|
||||
prepare_buffers_helper const* b_ = nullptr;
|
||||
buffer_prefix_helper const* b_ = nullptr;
|
||||
typename BufferSequence::const_iterator it_;
|
||||
|
||||
public:
|
||||
@ -171,7 +171,7 @@ public:
|
||||
operator*() const
|
||||
{
|
||||
if(it_ == b_->back_)
|
||||
return prepare_buffer(b_->size_, *it_);
|
||||
return buffer_prefix(b_->size_, *it_);
|
||||
return *it_;
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const_iterator(prepare_buffers_helper const& b,
|
||||
const_iterator(buffer_prefix_helper const& b,
|
||||
bool at_end)
|
||||
: b_(&b)
|
||||
, it_(at_end ? b.end_ : b.bs_.begin())
|
||||
@ -219,7 +219,7 @@ private:
|
||||
|
||||
template<class BufferSequence>
|
||||
void
|
||||
prepare_buffers_helper<BufferSequence>::
|
||||
buffer_prefix_helper<BufferSequence>::
|
||||
setup(std::size_t n)
|
||||
{
|
||||
for(end_ = bs_.begin(); end_ != bs_.end(); ++end_)
|
||||
@ -239,7 +239,7 @@ setup(std::size_t n)
|
||||
}
|
||||
|
||||
template<class BufferSequence>
|
||||
prepare_buffers_helper<BufferSequence>::const_iterator::
|
||||
buffer_prefix_helper<BufferSequence>::const_iterator::
|
||||
const_iterator(const_iterator&& other)
|
||||
: b_(other.b_)
|
||||
, it_(std::move(other.it_))
|
||||
@ -247,7 +247,7 @@ const_iterator(const_iterator&& other)
|
||||
}
|
||||
|
||||
template<class BufferSequence>
|
||||
prepare_buffers_helper<BufferSequence>::const_iterator::
|
||||
buffer_prefix_helper<BufferSequence>::const_iterator::
|
||||
const_iterator(const_iterator const& other)
|
||||
: b_(other.b_)
|
||||
, it_(other.it_)
|
||||
@ -256,7 +256,7 @@ const_iterator(const_iterator const& other)
|
||||
|
||||
template<class BufferSequence>
|
||||
auto
|
||||
prepare_buffers_helper<BufferSequence>::const_iterator::
|
||||
buffer_prefix_helper<BufferSequence>::const_iterator::
|
||||
operator=(const_iterator&& other) ->
|
||||
const_iterator&
|
||||
{
|
||||
@ -267,7 +267,7 @@ operator=(const_iterator&& other) ->
|
||||
|
||||
template<class BufferSequence>
|
||||
auto
|
||||
prepare_buffers_helper<BufferSequence>::const_iterator::
|
||||
buffer_prefix_helper<BufferSequence>::const_iterator::
|
||||
operator=(const_iterator const& other) ->
|
||||
const_iterator&
|
||||
{
|
||||
@ -279,18 +279,18 @@ operator=(const_iterator const& other) ->
|
||||
}
|
||||
|
||||
template<class BufferSequence>
|
||||
prepare_buffers_helper<BufferSequence>::
|
||||
prepare_buffers_helper(prepare_buffers_helper&& other)
|
||||
: prepare_buffers_helper(std::move(other),
|
||||
buffer_prefix_helper<BufferSequence>::
|
||||
buffer_prefix_helper(buffer_prefix_helper&& other)
|
||||
: buffer_prefix_helper(std::move(other),
|
||||
std::distance<iter_type>(other.bs_.begin(), other.back_),
|
||||
std::distance<iter_type>(other.bs_.begin(), other.end_))
|
||||
{
|
||||
}
|
||||
|
||||
template<class BufferSequence>
|
||||
prepare_buffers_helper<BufferSequence>::
|
||||
prepare_buffers_helper(prepare_buffers_helper const& other)
|
||||
: prepare_buffers_helper(other,
|
||||
buffer_prefix_helper<BufferSequence>::
|
||||
buffer_prefix_helper(buffer_prefix_helper const& other)
|
||||
: buffer_prefix_helper(other,
|
||||
std::distance<iter_type>(other.bs_.begin(), other.back_),
|
||||
std::distance<iter_type>(other.bs_.begin(), other.end_))
|
||||
{
|
||||
@ -298,9 +298,9 @@ prepare_buffers_helper(prepare_buffers_helper const& other)
|
||||
|
||||
template<class BufferSequence>
|
||||
auto
|
||||
prepare_buffers_helper<BufferSequence>::
|
||||
operator=(prepare_buffers_helper&& other) ->
|
||||
prepare_buffers_helper&
|
||||
buffer_prefix_helper<BufferSequence>::
|
||||
operator=(buffer_prefix_helper&& other) ->
|
||||
buffer_prefix_helper&
|
||||
{
|
||||
auto const nback = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.back_);
|
||||
@ -315,9 +315,9 @@ operator=(prepare_buffers_helper&& other) ->
|
||||
|
||||
template<class BufferSequence>
|
||||
auto
|
||||
prepare_buffers_helper<BufferSequence>::
|
||||
operator=(prepare_buffers_helper const& other) ->
|
||||
prepare_buffers_helper&
|
||||
buffer_prefix_helper<BufferSequence>::
|
||||
operator=(buffer_prefix_helper const& other) ->
|
||||
buffer_prefix_helper&
|
||||
{
|
||||
auto const nback = std::distance<iter_type>(
|
||||
other.bs_.begin(), other.back_);
|
||||
@ -331,8 +331,8 @@ operator=(prepare_buffers_helper const& other) ->
|
||||
}
|
||||
|
||||
template<class BufferSequence>
|
||||
prepare_buffers_helper<BufferSequence>::
|
||||
prepare_buffers_helper(std::size_t n, BufferSequence const& bs)
|
||||
buffer_prefix_helper<BufferSequence>::
|
||||
buffer_prefix_helper(std::size_t n, BufferSequence const& bs)
|
||||
: bs_(bs)
|
||||
{
|
||||
setup(n);
|
||||
@ -341,7 +341,7 @@ prepare_buffers_helper(std::size_t n, BufferSequence const& bs)
|
||||
template<class BufferSequence>
|
||||
inline
|
||||
auto
|
||||
prepare_buffers_helper<BufferSequence>::begin() const ->
|
||||
buffer_prefix_helper<BufferSequence>::begin() const ->
|
||||
const_iterator
|
||||
{
|
||||
return const_iterator{*this, false};
|
||||
@ -350,7 +350,7 @@ prepare_buffers_helper<BufferSequence>::begin() const ->
|
||||
template<class BufferSequence>
|
||||
inline
|
||||
auto
|
||||
prepare_buffers_helper<BufferSequence>::end() const ->
|
||||
buffer_prefix_helper<BufferSequence>::end() const ->
|
||||
const_iterator
|
||||
{
|
||||
return const_iterator{*this, true};
|
@ -14,9 +14,9 @@
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/prepare_buffer.hpp>
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <memory>
|
||||
|
@ -9,9 +9,9 @@
|
||||
#define BEAST_WEBSOCKET_IMPL_READ_IPP
|
||||
|
||||
#include <beast/websocket/teardown.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/prepare_buffer.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/clamp.hpp>
|
||||
@ -228,7 +228,7 @@ operator()(error_code ec,
|
||||
case do_read_payload + 2:
|
||||
{
|
||||
d.remain -= bytes_transferred;
|
||||
auto const pb = prepare_buffers(
|
||||
auto const pb = buffer_prefix(
|
||||
bytes_transferred, *d.dmb);
|
||||
if(d.fh.mask)
|
||||
detail::mask_inplace(pb, d.key);
|
||||
@ -864,7 +864,7 @@ read_frame(frame_info& fi, DynamicBuffer& dynabuf, error_code& ec)
|
||||
return;
|
||||
BOOST_ASSERT(bytes_transferred > 0);
|
||||
remain -= bytes_transferred;
|
||||
auto const pb = prepare_buffers(
|
||||
auto const pb = buffer_prefix(
|
||||
bytes_transferred, b);
|
||||
if(fh.mask)
|
||||
detail::mask_inplace(pb, key);
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include <beast/http/write.hpp>
|
||||
#include <beast/http/rfc7230.hpp>
|
||||
#include <beast/core/buffer_cat.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/prepare_buffer.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
|
@ -10,10 +10,10 @@
|
||||
|
||||
#include <beast/core/bind_handler.hpp>
|
||||
#include <beast/core/buffer_cat.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/prepare_buffer.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/clamp.hpp>
|
||||
@ -267,7 +267,7 @@ operator()(error_code ec,
|
||||
do_upcall : do_nomask_frag + 2;
|
||||
boost::asio::async_write(d.ws.stream_,
|
||||
buffer_cat(d.fh_buf.data(),
|
||||
prepare_buffers(n, d.cb)),
|
||||
buffer_prefix(n, d.cb)),
|
||||
std::move(*this));
|
||||
return;
|
||||
}
|
||||
@ -698,7 +698,7 @@ write_frame(bool fin,
|
||||
wr_.cont = ! fin;
|
||||
boost::asio::write(stream_,
|
||||
buffer_cat(fh_buf.data(),
|
||||
prepare_buffers(n, cb)), ec);
|
||||
buffer_prefix(n, cb)), ec);
|
||||
failed_ = ec != 0;
|
||||
if(failed_)
|
||||
return;
|
||||
@ -879,7 +879,7 @@ operator()(error_code ec, bool again)
|
||||
auto const fin = d.remain <= 0;
|
||||
if(fin)
|
||||
d.state = 99;
|
||||
auto const pb = prepare_buffers(n, d.cb);
|
||||
auto const pb = buffer_prefix(n, d.cb);
|
||||
d.cb.consume(n);
|
||||
d.ws.async_write_frame(fin, pb, std::move(*this));
|
||||
return;
|
||||
|
@ -19,6 +19,7 @@ unit-test core-tests :
|
||||
core/async_result.cpp
|
||||
core/bind_handler.cpp
|
||||
core/buffer_cat.cpp
|
||||
core/buffer_prefix.cpp
|
||||
core/buffered_read_stream.cpp
|
||||
core/buffers_adapter.cpp
|
||||
core/clamp.cpp
|
||||
@ -29,7 +30,6 @@ unit-test core-tests :
|
||||
core/handler_ptr.cpp
|
||||
core/multi_buffer.cpp
|
||||
core/ostream.cpp
|
||||
core/prepare_buffer.cpp
|
||||
core/static_buffer.cpp
|
||||
core/static_string.cpp
|
||||
core/string_view.cpp
|
||||
|
@ -12,6 +12,7 @@ add_executable (core-tests
|
||||
async_result.cpp
|
||||
bind_handler.cpp
|
||||
buffer_cat.cpp
|
||||
buffer_prefix.cpp
|
||||
buffers_adapter.cpp
|
||||
clamp.cpp
|
||||
consuming_buffers.cpp
|
||||
@ -22,7 +23,6 @@ add_executable (core-tests
|
||||
handler_ptr.cpp
|
||||
multi_buffer.cpp
|
||||
ostream.cpp
|
||||
prepare_buffer.cpp
|
||||
static_buffer.cpp
|
||||
static_string.cpp
|
||||
string_view.cpp
|
||||
|
@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <beast/core/prepare_buffer.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
namespace beast {
|
||||
|
||||
class prepare_buffer_test : public beast::unit_test::suite
|
||||
class buffer_prefix_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
template<class ConstBufferSequence>
|
||||
@ -100,14 +100,14 @@ public:
|
||||
BufferType{&s[x+y], z}}};
|
||||
for(std::size_t i = 0; i <= s.size() + 1; ++i)
|
||||
{
|
||||
auto pb = prepare_buffers(i, bs);
|
||||
auto pb = buffer_prefix(i, bs);
|
||||
BEAST_EXPECT(to_string(pb) == s.substr(0, i));
|
||||
auto pb2 = pb;
|
||||
BEAST_EXPECT(to_string(pb2) == to_string(pb));
|
||||
pb = prepare_buffers(0, bs);
|
||||
pb = buffer_prefix(0, bs);
|
||||
pb2 = pb;
|
||||
BEAST_EXPECT(buffer_size(pb2) == 0);
|
||||
pb2 = prepare_buffers(i, bs);
|
||||
pb2 = buffer_prefix(i, bs);
|
||||
BEAST_EXPECT(to_string(pb2) == s.substr(0, i));
|
||||
}
|
||||
}
|
||||
@ -119,9 +119,9 @@ public:
|
||||
using boost::asio::buffer_copy;
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::null_buffers;
|
||||
auto pb0 = prepare_buffers(0, null_buffers{});
|
||||
auto pb0 = buffer_prefix(0, null_buffers{});
|
||||
BEAST_EXPECT(buffer_size(pb0) == 0);
|
||||
auto pb1 = prepare_buffers(1, null_buffers{});
|
||||
auto pb1 = buffer_prefix(1, null_buffers{});
|
||||
BEAST_EXPECT(buffer_size(pb1) == 0);
|
||||
BEAST_EXPECT(buffer_copy(pb0, pb1) == 0);
|
||||
|
||||
@ -133,7 +133,7 @@ public:
|
||||
BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
BEAST_EXPECT(buffer_copy(cb, pb1) == 0);
|
||||
|
||||
auto pbc = prepare_buffers(2, cb);
|
||||
auto pbc = buffer_prefix(2, cb);
|
||||
BEAST_EXPECT(buffer_size(pbc) == 0);
|
||||
BEAST_EXPECT(buffer_copy(pbc, cb) == 0);
|
||||
}
|
||||
@ -147,7 +147,7 @@ public:
|
||||
const_buffer{&b[0], 1},
|
||||
const_buffer{&b[1], 1},
|
||||
const_buffer{&b[2], 1}}};
|
||||
auto pb = prepare_buffers(2, bs);
|
||||
auto pb = buffer_prefix(2, bs);
|
||||
BEAST_EXPECT(bsize1(pb) == 2);
|
||||
BEAST_EXPECT(bsize2(pb) == 2);
|
||||
BEAST_EXPECT(bsize3(pb) == 2);
|
||||
@ -172,6 +172,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(prepare_buffer,core,beast);
|
||||
BEAST_DEFINE_TESTSUITE(buffer_prefix,core,beast);
|
||||
|
||||
} // beast
|
@ -5,8 +5,8 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/flat_buffer.hpp>
|
||||
#include <beast/core/prepare_buffer.hpp>
|
||||
#include <beast/http/chunk_encode.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
|
Reference in New Issue
Block a user