From e4a204b145832a6c84671e63526465f84052572e Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 27 Apr 2017 18:26:21 -0700 Subject: [PATCH] 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 --- CHANGELOG.md | 1 + README.md | 2 +- doc/examples.qbk | 2 +- doc/http.qbk | 2 +- doc/quickref.xml | 4 +-- examples/http_example.cpp | 2 +- examples/ssl/http_ssl_example.cpp | 2 +- include/beast/http.hpp | 2 +- ...asic_dynabuf_body.hpp => dynamic_body.hpp} | 19 ++++++++----- include/beast/http/streambuf_body.hpp | 27 ------------------- include/beast/websocket/impl/handshake.ipp | 1 - test/Jamfile | 3 +-- test/http/CMakeLists.txt | 3 +-- test/http/basic_dynabuf_body.cpp | 9 ------- .../{streambuf_body.cpp => dynamic_body.cpp} | 8 +++--- test/http/parser_bench.cpp | 8 +++--- test/http/read.cpp | 18 ++++++------- 17 files changed, 40 insertions(+), 73 deletions(-) rename include/beast/http/{basic_dynabuf_body.hpp => dynamic_body.hpp} (83%) delete mode 100644 include/beast/http/streambuf_body.hpp delete mode 100644 test/http/basic_dynabuf_body.cpp rename test/http/{streambuf_body.cpp => dynamic_body.cpp} (84%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f68472b..cf715cae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 -------------------------------------------------------------------------------- diff --git a/README.md b/README.md index a55fe9ca..e9479e46 100644 --- a/README.md +++ b/README.md @@ -251,7 +251,7 @@ int main() // Receive and print HTTP response using beast beast::streambuf sb; - beast::http::response resp; + beast::http::response resp; beast::http::read(sock, sb, resp); std::cout << resp; } diff --git a/doc/examples.qbk b/doc/examples.qbk index 8cbb2f7d..708e33f0 100644 --- a/doc/examples.qbk +++ b/doc/examples.qbk @@ -46,7 +46,7 @@ int main() // Receive and print HTTP response using beast beast::streambuf sb; - beast::http::response resp; + beast::http::response resp; beast::http::read(sock, sb, resp); std::cout << resp; } diff --git a/doc/http.qbk b/doc/http.qbk index d08a3046..b9d520bf 100644 --- a/doc/http.qbk +++ b/doc/http.qbk @@ -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. diff --git a/doc/quickref.xml b/doc/quickref.xml index f623a339..e81e0eb5 100644 --- a/doc/quickref.xml +++ b/doc/quickref.xml @@ -29,9 +29,10 @@ Classes - basic_dynabuf_body + http__basic_dynamic_body basic_fields basic_parser + dynamic_body fields header header_parser @@ -41,7 +42,6 @@ request_header response response_header - streambuf_body string_body rfc7230 diff --git a/examples/http_example.cpp b/examples/http_example.cpp index 6c060817..d58524f5 100644 --- a/examples/http_example.cpp +++ b/examples/http_example.cpp @@ -34,7 +34,7 @@ int main() // Receive and print HTTP response using beast beast::streambuf sb; - beast::http::response resp; + beast::http::response resp; beast::http::read(sock, sb, resp); std::cout << resp; } diff --git a/examples/ssl/http_ssl_example.cpp b/examples/ssl/http_ssl_example.cpp index 3b9992b4..cb9391ec 100644 --- a/examples/ssl/http_ssl_example.cpp +++ b/examples/ssl/http_ssl_example.cpp @@ -46,7 +46,7 @@ int main() // Receive and print HTTP response using Beast beast::streambuf sb; - beast::http::response resp; + beast::http::response resp; beast::http::read(stream, sb, resp); std::cout << resp; diff --git a/include/beast/http.hpp b/include/beast/http.hpp index e3b7ed2d..6d0e41f6 100644 --- a/include/beast/http.hpp +++ b/include/beast/http.hpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -21,7 +22,6 @@ #include #include #include -#include #include #include diff --git a/include/beast/http/basic_dynabuf_body.hpp b/include/beast/http/dynamic_body.hpp similarity index 83% rename from include/beast/http/basic_dynabuf_body.hpp rename to include/beast/http/dynamic_body.hpp index 8ad5f691..caead1cd 100644 --- a/include/beast/http/basic_dynabuf_body.hpp +++ b/include/beast/http/dynamic_body.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 #include +#include #include -#include -#include namespace beast { namespace http { @@ -22,7 +21,7 @@ namespace http { Meets the requirements of @b `Body`. */ template -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 explicit reader(message& msg) + basic_dynamic_body, Fields>& msg) : body_(msg.body) { } @@ -85,7 +84,7 @@ private: template 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; + } // http } // beast diff --git a/include/beast/http/streambuf_body.hpp b/include/beast/http/streambuf_body.hpp deleted file mode 100644 index 974a3f3c..00000000 --- a/include/beast/http/streambuf_body.hpp +++ /dev/null @@ -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 -#include -#include - -namespace beast { -namespace http { - -/** A message body represented by a @ref streambuf - - Meets the requirements of @b `Body`. -*/ -using streambuf_body = basic_dynabuf_body; - -} // http -} // beast - -#endif diff --git a/include/beast/websocket/impl/handshake.ipp b/include/beast/websocket/impl/handshake.ipp index 07569b6c..534ca2e1 100644 --- a/include/beast/websocket/impl/handshake.ipp +++ b/include/beast/websocket/impl/handshake.ipp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/test/Jamfile b/test/Jamfile index 12d4c9ce..d39b7292 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -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 diff --git a/test/http/CMakeLists.txt b/test/http/CMakeLists.txt index 0efd824e..b259b905 100644 --- a/test/http/CMakeLists.txt +++ b/test/http/CMakeLists.txt @@ -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 diff --git a/test/http/basic_dynabuf_body.cpp b/test/http/basic_dynabuf_body.cpp deleted file mode 100644 index a8a449c2..00000000 --- a/test/http/basic_dynabuf_body.cpp +++ /dev/null @@ -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 diff --git a/test/http/streambuf_body.cpp b/test/http/dynamic_body.cpp similarity index 84% rename from test/http/streambuf_body.cpp rename to test/http/dynamic_body.cpp index 9e796c6b..77b86a91 100644 --- a/test/http/streambuf_body.cpp +++ b/test/http/dynamic_body.cpp @@ -6,7 +6,7 @@ // // Test that header file is self-contained. -#include +#include #include #include @@ -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 p; + message_parser 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 diff --git a/test/http/parser_bench.cpp b/test/http/parser_bench.cpp index 5015738e..bf555f9b 100644 --- a/test/http/parser_bench.cpp +++ b/test/http/parser_bench.cpp @@ -239,20 +239,20 @@ public: [&] { testParser1>( + true, dynamic_body, fields>>( Repeat, creq_); testParser1>( + false, dynamic_body, fields>>( Repeat, cres_); }); timedTest(Trials, "http::basic_parser", [&] { testParser2 >( + true, dynamic_body, fields> >( Repeat, creq_); testParser2>( + false, dynamic_body, fields>>( Repeat, cres_); }); pass(); diff --git a/test/http/read.cpp b/test/http/read.cpp index 3e80b8eb..a03f1f3b 100644 --- a/test/http/read.cpp +++ b/test/http/read.cpp @@ -11,8 +11,8 @@ #include "test_parser.hpp" #include +#include #include -#include #include #include #include @@ -108,7 +108,7 @@ public: { streambuf sb; test::string_istream ss(ios_, "GET / X"); - message_parser p; + message_parser p; read(ss, sb, p); fail(); } @@ -194,7 +194,7 @@ public: "Content-Length: 0\r\n" "\r\n" ); - request m; + request m; try { streambuf sb; @@ -216,7 +216,7 @@ public: "Content-Length: 0\r\n" "\r\n" ); - request m; + request m; error_code ec; streambuf sb; read(fs, sb, m, ec); @@ -234,7 +234,7 @@ public: "Content-Length: 0\r\n" "\r\n" ); - request m; + request 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 p; + message_parser 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 p; + message_parser 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 m; + message 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 m; + message m; async_read(is, sb, m, handler{}); BEAST_EXPECT(handler::count() > 0); }