Remove string_view_body

Actions Required:

* Use span_body<char> instead of string_view_body
This commit is contained in:
Vinnie Falco
2017-07-10 06:48:20 -07:00
parent fa45e6ad07
commit 5788ed2574
10 changed files with 7 additions and 147 deletions

View File

@@ -19,12 +19,15 @@ API Changes:
* Add message::keep_alive() * Add message::keep_alive()
* Add message::chunked() and message::content_length() * Add message::chunked() and message::content_length()
* Remove string_view_body
Actions Required: Actions Required:
* Change user defined implementations of Fields and * Change user defined implementations of Fields and
FieldsReader to meet the new requirements. FieldsReader to meet the new requirements.
* Use span_body<char> instead of string_view_body
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Version 77: Version 77:

View File

@@ -170,14 +170,6 @@ meet the requirements, or use the ones that come with the library:
grows geometrically. Messages with this body type may be serialized grows geometrically. Messages with this body type may be serialized
and parsed. This is the type of body used in the examples. and parsed. This is the type of body used in the examples.
]] ]]
[[
[link beast.ref.beast__http__string_view_body `string_view_body`]
][
A body whose `value_type` is [link beast.ref.beast__string_view `string_view`].
Messages with this body type may be serialized only, and the caller
is responsible for managing the lifetime of the buffer pointed to
by the string view.
]]
[[ [[
[link beast.ref.beast__http__vector_body `vector_body`] [link beast.ref.beast__http__vector_body `vector_body`]
][ ][

View File

@@ -101,6 +101,5 @@ In this table:
* [link beast.ref.beast__http__dynamic_body `dynamic_body`] * [link beast.ref.beast__http__dynamic_body `dynamic_body`]
* [link beast.ref.beast__http__empty_body `empty_body`] * [link beast.ref.beast__http__empty_body `empty_body`]
* [link beast.ref.beast__http__string_body `string_body`] * [link beast.ref.beast__http__string_body `string_body`]
* [link beast.ref.beast__http__string_view_body `string_view_body`]
[endsect] [endsect]

View File

@@ -53,7 +53,6 @@
<member><link linkend="beast.ref.beast__http__serializer">serializer</link></member> <member><link linkend="beast.ref.beast__http__serializer">serializer</link></member>
<member><link linkend="beast.ref.beast__http__span_body">span_body</link></member> <member><link linkend="beast.ref.beast__http__span_body">span_body</link></member>
<member><link linkend="beast.ref.beast__http__string_body">string_body</link></member> <member><link linkend="beast.ref.beast__http__string_body">string_body</link></member>
<member><link linkend="beast.ref.beast__http__string_view_body">string_view_body</link></member>
<member><link linkend="beast.ref.beast__http__vector_body">vector_body</link></member> <member><link linkend="beast.ref.beast__http__vector_body">vector_body</link></member>
</simplelist> </simplelist>
</entry> </entry>

View File

@@ -26,7 +26,6 @@
#include <beast/http/span_body.hpp> #include <beast/http/span_body.hpp>
#include <beast/http/status.hpp> #include <beast/http/status.hpp>
#include <beast/http/string_body.hpp> #include <beast/http/string_body.hpp>
#include <beast/http/string_view_body.hpp>
#include <beast/http/type_traits.hpp> #include <beast/http/type_traits.hpp>
#include <beast/http/vector_body.hpp> #include <beast/http/vector_body.hpp>
#include <beast/http/verb.hpp> #include <beast/http/verb.hpp>

View File

@@ -136,7 +136,11 @@ public:
}; };
/// The algorithm used to serialize the header /// The algorithm used to serialize the header
#if BEAST_DOXYGEN
using reader = implementation_defined;
#else
class reader; class reader;
#endif
private: private:
using list_t = typename boost::intrusive::make_list< using list_t = typename boost::intrusive::make_list<

View File

@@ -1,81 +0,0 @@
//
// Copyright (c) 2013-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)
//
#ifndef BEAST_HTTP_STRING_VIEW_BODY
#define BEAST_HTTP_STRING_VIEW_BODY
#include <beast/config.hpp>
#include <beast/core/string.hpp>
#include <beast/http/message.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/optional.hpp>
#include <utility>
namespace beast {
namespace http {
/** A readable HTTP message body represented by a @ref string_view.
The application must ensure that the memory pointed to
by the string view remains valid for the lifetime of
any attempted operations.
Meets the requirements of @b Body.
*/
struct string_view_body
{
/// The type of the body member when used in a message.
using value_type = string_view;
/// Returns the content length of this body in a message.
static
std::uint64_t
size(value_type const& v)
{
return v.size();
}
#if BEAST_DOXYGEN
/// The algorithm to obtain buffers representing the body
using reader = implementation_defined;
#else
class reader
{
string_view body_;
public:
using const_buffers_type =
boost::asio::const_buffers_1;
template<bool isRequest, class Fields>
explicit
reader(message<isRequest,
string_view_body, Fields> const& m)
: body_(m.body)
{
}
void
init(error_code& ec)
{
ec.assign(0, ec.category());
}
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec)
{
ec.assign(0, ec.category());
return {{{body_.data(), body_.size()}, false}};
}
};
#endif
};
} // http
} // beast
#endif

View File

@@ -31,7 +31,6 @@ add_executable (http-tests
span_body.cpp span_body.cpp
status.cpp status.cpp
string_body.cpp string_body.cpp
string_view_body.cpp
type_traits.cpp type_traits.cpp
vector_body.cpp vector_body.cpp
verb.cpp verb.cpp

View File

@@ -24,7 +24,6 @@ unit-test http-tests :
span_body.cpp span_body.cpp
status.cpp status.cpp
string_body.cpp string_body.cpp
string_view_body.cpp
type_traits.cpp type_traits.cpp
vector_body.cpp vector_body.cpp
verb.cpp verb.cpp

View File

@@ -1,53 +0,0 @@
//
// Copyright (c) 2013-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)
//
// Test that header file is self-contained.
#include <beast/http/string_view_body.hpp>
#include <beast/core/ostream.hpp>
#include <beast/core/static_buffer.hpp>
#include <beast/http/message.hpp>
#include <beast/http/write.hpp>
#include <beast/http/type_traits.hpp>
#include <beast/unit_test/suite.hpp>
namespace beast {
namespace http {
class string_view_body_test
: public beast::unit_test::suite
{
public:
void
run() override
{
static_assert(is_body_reader<string_view_body>::value, "");
static_assert(! is_body_writer<string_view_body>::value, "");
request<string_view_body> req;
req.version = 11;
req.method(verb::post);
req.target("/");
req.body = "Hello, world!";
req.prepare_payload();
static_buffer_n<512> b;
ostream(b) << req;
string_view const s{
boost::asio::buffer_cast<char const*>(*b.data().begin()),
boost::asio::buffer_size(*b.data().begin())};
BEAST_EXPECT(s ==
"POST / HTTP/1.1\r\n"
"Content-Length: 13\r\n"
"\r\n"
"Hello, world!");
}
};
BEAST_DEFINE_TESTSUITE(string_view_body,http,beast);
} // http
} // beast