mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 14:54:32 +02:00
Rename to http::dynamic_body, consolidate header:
fix #284 * streambuf_body is renamed to dynamic_body * basic_dynabuf_body is renamed to basic_dynamic_body
This commit is contained in:
@@ -15,6 +15,7 @@ API Changes:
|
||||
* Provide websocket::stream accept() overloads
|
||||
* Refactor websocket decorators
|
||||
* Move everything in basic_fields.hpp to fields.hpp
|
||||
* Rename to http::dynamic_body, consolidate header
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -251,7 +251,7 @@ int main()
|
||||
|
||||
// Receive and print HTTP response using beast
|
||||
beast::streambuf sb;
|
||||
beast::http::response<beast::http::streambuf_body> resp;
|
||||
beast::http::response<beast::http::dynamic_body> resp;
|
||||
beast::http::read(sock, sb, resp);
|
||||
std::cout << resp;
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ int main()
|
||||
|
||||
// Receive and print HTTP response using beast
|
||||
beast::streambuf sb;
|
||||
beast::http::response<beast::http::streambuf_body> resp;
|
||||
beast::http::response<beast::http::dynamic_body> resp;
|
||||
beast::http::read(sock, sb, resp);
|
||||
std::cout << resp;
|
||||
}
|
||||
|
@@ -237,7 +237,7 @@ used in the examples:
|
||||
res.body = "Here is the data you requested";
|
||||
```
|
||||
|
||||
* [link beast.ref.http__streambuf_body [*`streambuf_body`:]] A body with a
|
||||
* [link beast.ref.http__dynamic_body [*`dynamic_body`:]] A body with a
|
||||
`value_type` of [link beast.ref.streambuf `streambuf`]: an efficient storage
|
||||
object which uses multiple octet arrays of varying lengths to represent data.
|
||||
|
||||
|
@@ -29,9 +29,10 @@
|
||||
<entry valign="top">
|
||||
<bridgehead renderas="sect3">Classes</bridgehead>
|
||||
<simplelist type="vert" columns="1">
|
||||
<member><link linkend="beast.ref.http__basic_dynabuf_body">basic_dynabuf_body</link></member>
|
||||
<member><link linkend="beast.ref.http__basic_dynamic_body">http__basic_dynamic_body</link></member>
|
||||
<member><link linkend="beast.ref.http__basic_fields">basic_fields</link></member>
|
||||
<member><link linkend="beast.ref.http__basic_parser">basic_parser</link></member>
|
||||
<member><link linkend="beast.ref.http__dynamic_body">dynamic_body</link></member>
|
||||
<member><link linkend="beast.ref.http__fields">fields</link></member>
|
||||
<member><link linkend="beast.ref.http__header">header</link></member>
|
||||
<member><link linkend="beast.ref.http__header_parser">header_parser</link></member>
|
||||
@@ -41,7 +42,6 @@
|
||||
<member><link linkend="beast.ref.http__request_header">request_header</link></member>
|
||||
<member><link linkend="beast.ref.http__response">response</link></member>
|
||||
<member><link linkend="beast.ref.http__response_header">response_header</link></member>
|
||||
<member><link linkend="beast.ref.http__streambuf_body">streambuf_body</link></member>
|
||||
<member><link linkend="beast.ref.http__string_body">string_body</link></member>
|
||||
</simplelist>
|
||||
<bridgehead renderas="sect3">rfc7230</bridgehead>
|
||||
|
@@ -34,7 +34,7 @@ int main()
|
||||
|
||||
// Receive and print HTTP response using beast
|
||||
beast::streambuf sb;
|
||||
beast::http::response<beast::http::streambuf_body> resp;
|
||||
beast::http::response<beast::http::dynamic_body> resp;
|
||||
beast::http::read(sock, sb, resp);
|
||||
std::cout << resp;
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ int main()
|
||||
|
||||
// Receive and print HTTP response using Beast
|
||||
beast::streambuf sb;
|
||||
beast::http::response<beast::http::streambuf_body> resp;
|
||||
beast::http::response<beast::http::dynamic_body> resp;
|
||||
beast::http::read(stream, sb, resp);
|
||||
std::cout << resp;
|
||||
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <beast/http/basic_parser.hpp>
|
||||
#include <beast/http/chunk_encode.hpp>
|
||||
#include <beast/http/dynamic_body.hpp>
|
||||
#include <beast/http/error.hpp>
|
||||
#include <beast/http/fields.hpp>
|
||||
#include <beast/http/header_parser.hpp>
|
||||
@@ -21,7 +22,6 @@
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/reason.hpp>
|
||||
#include <beast/http/rfc7230.hpp>
|
||||
#include <beast/http/streambuf_body.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
|
||||
|
@@ -5,14 +5,13 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BEAST_HTTP_BASIC_DYNABUF_BODY_HPP
|
||||
#define BEAST_HTTP_BASIC_DYNABUF_BODY_HPP
|
||||
#ifndef BEAST_HTTP_DYNAMIC_BODY_HPP
|
||||
#define BEAST_HTTP_DYNAMIC_BODY_HPP
|
||||
|
||||
#include <beast/config.hpp>
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/core/streambuf.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
|
||||
namespace beast {
|
||||
namespace http {
|
||||
@@ -22,7 +21,7 @@ namespace http {
|
||||
Meets the requirements of @b `Body`.
|
||||
*/
|
||||
template<class DynamicBuffer>
|
||||
struct basic_dynabuf_body
|
||||
struct basic_dynamic_body
|
||||
{
|
||||
/// The type of the `message::body` member
|
||||
using value_type = DynamicBuffer;
|
||||
@@ -44,7 +43,7 @@ private:
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
reader(message<isRequest,
|
||||
basic_dynabuf_body, Fields>& msg)
|
||||
basic_dynamic_body, Fields>& msg)
|
||||
: body_(msg.body)
|
||||
{
|
||||
}
|
||||
@@ -85,7 +84,7 @@ private:
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<
|
||||
isRequest, basic_dynabuf_body, Fields> const& m) noexcept
|
||||
isRequest, basic_dynamic_body, Fields> const& m) noexcept
|
||||
: body_(m.body)
|
||||
{
|
||||
}
|
||||
@@ -112,6 +111,12 @@ private:
|
||||
};
|
||||
};
|
||||
|
||||
/** A dynamic message body represented by a @ref streambuf
|
||||
|
||||
Meets the requirements of @b `Body`.
|
||||
*/
|
||||
using dynamic_body = basic_dynamic_body<streambuf>;
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
|
@@ -1,27 +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_STREAMBUF_BODY_HPP
|
||||
#define BEAST_HTTP_STREAMBUF_BODY_HPP
|
||||
|
||||
#include <beast/config.hpp>
|
||||
#include <beast/http/basic_dynabuf_body.hpp>
|
||||
#include <beast/core/streambuf.hpp>
|
||||
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
/** A message body represented by a @ref streambuf
|
||||
|
||||
Meets the requirements of @b `Body`.
|
||||
*/
|
||||
using streambuf_body = basic_dynabuf_body<streambuf>;
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
|
||||
#endif
|
@@ -11,7 +11,6 @@
|
||||
#include <beast/websocket/detail/type_traits.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/streambuf_body.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
|
@@ -47,10 +47,10 @@ unit-test core-tests :
|
||||
|
||||
unit-test http-tests :
|
||||
../extras/beast/unit_test/main.cpp
|
||||
http/basic_dynabuf_body.cpp
|
||||
http/basic_parser.cpp
|
||||
http/concepts.cpp
|
||||
http/design.cpp
|
||||
http/dynamic_body.cpp
|
||||
http/error.cpp
|
||||
http/fields.cpp
|
||||
http/header_parser.cpp
|
||||
@@ -59,7 +59,6 @@ unit-test http-tests :
|
||||
http/read.cpp
|
||||
http/reason.cpp
|
||||
http/rfc7230.cpp
|
||||
http/streambuf_body.cpp
|
||||
http/string_body.cpp
|
||||
http/write.cpp
|
||||
http/chunk_encode.cpp
|
||||
|
@@ -10,10 +10,10 @@ add_executable (http-tests
|
||||
message_fuzz.hpp
|
||||
test_parser.hpp
|
||||
../../extras/beast/unit_test/main.cpp
|
||||
basic_dynabuf_body.cpp
|
||||
basic_parser.cpp
|
||||
concepts.cpp
|
||||
design.cpp
|
||||
dynamic_body.cpp
|
||||
error.cpp
|
||||
fields.cpp
|
||||
header_parser.cpp
|
||||
@@ -22,7 +22,6 @@ add_executable (http-tests
|
||||
read.cpp
|
||||
reason.cpp
|
||||
rfc7230.cpp
|
||||
streambuf_body.cpp
|
||||
string_body.cpp
|
||||
write.cpp
|
||||
chunk_encode.cpp
|
||||
|
@@ -1,9 +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/basic_dynabuf_body.hpp>
|
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <beast/http/streambuf_body.hpp>
|
||||
#include <beast/http/dynamic_body.hpp>
|
||||
|
||||
#include <beast/core/to_string.hpp>
|
||||
#include <beast/http/fields.hpp>
|
||||
@@ -20,7 +20,7 @@
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
class streambuf_body_test : public beast::unit_test::suite
|
||||
class dynamic_body_test : public beast::unit_test::suite
|
||||
{
|
||||
boost::asio::io_service ios_;
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
"\r\n"
|
||||
"xyz";
|
||||
test::string_istream ss(ios_, s);
|
||||
message_parser<false, streambuf_body, fields> p;
|
||||
message_parser<false, dynamic_body, fields> p;
|
||||
streambuf sb;
|
||||
read(ss, sb, p);
|
||||
auto const& m = p.get();
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(streambuf_body,http,beast);
|
||||
BEAST_DEFINE_TESTSUITE(dynamic_body,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
@@ -239,20 +239,20 @@ public:
|
||||
[&]
|
||||
{
|
||||
testParser1<nodejs_parser<
|
||||
true, streambuf_body, fields>>(
|
||||
true, dynamic_body, fields>>(
|
||||
Repeat, creq_);
|
||||
testParser1<nodejs_parser<
|
||||
false, streambuf_body, fields>>(
|
||||
false, dynamic_body, fields>>(
|
||||
Repeat, cres_);
|
||||
});
|
||||
timedTest(Trials, "http::basic_parser",
|
||||
[&]
|
||||
{
|
||||
testParser2<bench_parser<
|
||||
true, streambuf_body, fields> >(
|
||||
true, dynamic_body, fields> >(
|
||||
Repeat, creq_);
|
||||
testParser2<bench_parser<
|
||||
false, streambuf_body, fields>>(
|
||||
false, dynamic_body, fields>>(
|
||||
Repeat, cres_);
|
||||
});
|
||||
pass();
|
||||
|
@@ -11,8 +11,8 @@
|
||||
#include "test_parser.hpp"
|
||||
|
||||
#include <beast/http/fields.hpp>
|
||||
#include <beast/http/dynamic_body.hpp>
|
||||
#include <beast/http/header_parser.hpp>
|
||||
#include <beast/http/streambuf_body.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/test/fail_stream.hpp>
|
||||
#include <beast/test/string_istream.hpp>
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
{
|
||||
streambuf sb;
|
||||
test::string_istream ss(ios_, "GET / X");
|
||||
message_parser<true, streambuf_body, fields> p;
|
||||
message_parser<true, dynamic_body, fields> p;
|
||||
read(ss, sb, p);
|
||||
fail();
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
"Content-Length: 0\r\n"
|
||||
"\r\n"
|
||||
);
|
||||
request<streambuf_body> m;
|
||||
request<dynamic_body> m;
|
||||
try
|
||||
{
|
||||
streambuf sb;
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
"Content-Length: 0\r\n"
|
||||
"\r\n"
|
||||
);
|
||||
request<streambuf_body> m;
|
||||
request<dynamic_body> m;
|
||||
error_code ec;
|
||||
streambuf sb;
|
||||
read(fs, sb, m, ec);
|
||||
@@ -234,7 +234,7 @@ public:
|
||||
"Content-Length: 0\r\n"
|
||||
"\r\n"
|
||||
);
|
||||
request<streambuf_body> m;
|
||||
request<dynamic_body> m;
|
||||
error_code ec;
|
||||
streambuf sb;
|
||||
async_read(fs, sb, m, do_yield[ec]);
|
||||
@@ -250,7 +250,7 @@ public:
|
||||
{
|
||||
streambuf sb;
|
||||
test::string_istream ss(ios_, "");
|
||||
message_parser<true, streambuf_body, fields> p;
|
||||
message_parser<true, dynamic_body, fields> p;
|
||||
error_code ec;
|
||||
read(ss, sb, p, ec);
|
||||
BEAST_EXPECT(ec == boost::asio::error::eof);
|
||||
@@ -258,7 +258,7 @@ public:
|
||||
{
|
||||
streambuf sb;
|
||||
test::string_istream ss(ios_, "");
|
||||
message_parser<true, streambuf_body, fields> p;
|
||||
message_parser<true, dynamic_body, fields> p;
|
||||
error_code ec;
|
||||
async_read(ss, sb, p, do_yield[ec]);
|
||||
BEAST_EXPECT(ec == boost::asio::error::eof);
|
||||
@@ -287,7 +287,7 @@ public:
|
||||
"GET / HTTP/1.1\r\n\r\n"};
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
streambuf sb;
|
||||
message<true, streambuf_body, fields> m;
|
||||
message<true, dynamic_body, fields> m;
|
||||
async_read(is, sb, m, handler{});
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
ios.stop();
|
||||
@@ -306,7 +306,7 @@ public:
|
||||
"GET / HTTP/1.1\r\n\r\n"};
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
streambuf sb;
|
||||
message<true, streambuf_body, fields> m;
|
||||
message<true, dynamic_body, fields> m;
|
||||
async_read(is, sb, m, handler{});
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user