From b9bdb1bbbc624fa1db79a381b039ab7eacd7bff7 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sat, 27 May 2017 22:49:22 -0700 Subject: [PATCH] Remove HTTP header aliases (API Change): fix #382 * request_header and response_header are removed --- CHANGELOG.md | 4 ++ doc/http.qbk | 56 ++----------------------- doc/quickref.xml | 2 - include/beast/http/message.hpp | 30 ++++++------- include/beast/websocket/impl/accept.ipp | 2 +- include/beast/websocket/impl/stream.ipp | 2 +- include/beast/websocket/stream.hpp | 4 +- test/http/message.cpp | 4 +- test/websocket/rfc6455.cpp | 2 +- 9 files changed, 27 insertions(+), 79 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edd7dc57..ea58d269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Version 46 * Add test::pipe +API Changes: + +* Remove HTTP header aliases + -------------------------------------------------------------------------------- Version 45 diff --git a/doc/http.qbk b/doc/http.qbk index e4a3cb1d..c9981e2d 100644 --- a/doc/http.qbk +++ b/doc/http.qbk @@ -5,47 +5,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ] -[/ -ideas: - - complete send request walkthrough (client) - - complete receive response walkthrough (client) - - complete receive request walkthrough (server) - - complete send response walkthrough (server) - - - Introduce concepts from simple to complex - - Smooth progression of new ideas building on the previous ideas - - - do we show a simplified message with collapsed fields? - - do we introduce `header` or `message` first? - - -contents: - Message (and header, fields) - Create request - Create response - Algorithms - Write - Read - Examples - Send Request - Receive Response - Receive Request - Send Response - Advanced - Responding to HEAD - Expect: 100-continue - Body (user defined) - - -section beast.http.examples Examples - -note - In the example code which follows, `socket` refers to an object of type - `boost::asio::ip::tcp::socket` which is currently connected to a remote peer. -] - - - [section:http Using HTTP] [block ''' @@ -76,8 +35,6 @@ writing of messages and headers in the HTTP/1 wire format using Boost.Asio. - - [section:message Message] The HTTP protocol defines the client and server roles: clients send messages @@ -118,18 +75,17 @@ __message__ class templates, as well as the inheritance relationship: For notational convenience, these template type aliases are provided which supply typical choices for the [*`Fields`] type: ``` -using request_header = header; -using response_header = header; - +/// A typical HTTP request template using request = message; +/// A typical HTTP response template using response = message; ``` -The code examples below show how to create and fill in a request and response -object: +The code examples below show how to create and fill in request and response +objects: [table Create Message [[HTTP Request] [HTTP Response]] @@ -181,14 +137,10 @@ results when serialized. Note that only the response has a body: ``` ]]] - - - [endsect] - [section:fields Fields] The [*`Fields`] type represents a container that can set or retrieve the diff --git a/doc/quickref.xml b/doc/quickref.xml index 487761c4..d00a8ee2 100644 --- a/doc/quickref.xml +++ b/doc/quickref.xml @@ -39,9 +39,7 @@ message message_parser request - request_header response - response_header string_body rfc7230 diff --git a/include/beast/http/message.hpp b/include/beast/http/message.hpp index d1a6d2fd..8719c060 100644 --- a/include/beast/http/message.hpp +++ b/include/beast/http/message.hpp @@ -20,7 +20,6 @@ namespace beast { namespace http { -#if BEAST_DOXYGEN /** A container for a HTTP request or response header. A header includes the Start Line and Fields. @@ -33,11 +32,12 @@ namespace http { @li Invoke algorithms which operate on the header only. */ -template +#if BEAST_DOXYGEN +template struct header #else -template +template struct header; template @@ -285,7 +285,7 @@ struct header @tparam Fields The type of container used to hold the field value pairs. */ -template +template struct message : header { /// The base class used to hold the header portion of the message. @@ -442,6 +442,14 @@ private: } }; +/// A typical HTTP request +template +using request = message; + +/// A typical HTTP response +template +using response = message; + //------------------------------------------------------------------------------ #if BEAST_DOXYGEN @@ -468,20 +476,6 @@ swap( message& m1, message& m2); -/// A typical HTTP request header -using request_header = header; - -/// Typical HTTP response header -using response_header = header; - -/// A typical HTTP request -template -using request = message; - -/// A typical HTTP response -template -using response = message; - //------------------------------------------------------------------------------ /** Returns `true` if the HTTP/1 message indicates a keep alive. diff --git a/include/beast/websocket/impl/accept.ipp b/include/beast/websocket/impl/accept.ipp index 962d6ac0..fd4bb03d 100644 --- a/include/beast/websocket/impl/accept.ipp +++ b/include/beast/websocket/impl/accept.ipp @@ -39,7 +39,7 @@ class stream::response_op { bool cont; stream& ws; - http::response_header res; + http::header res; int state = 0; template diff --git a/include/beast/websocket/impl/stream.ipp b/include/beast/websocket/impl/stream.ipp index 346cb90a..9e6c0a23 100644 --- a/include/beast/websocket/impl/stream.ipp +++ b/include/beast/websocket/impl/stream.ipp @@ -282,7 +282,7 @@ build_response(request_type const& req, template void stream:: -do_response(http::response_header const& res, +do_response(http::header const& res, detail::sec_ws_key_type const& key, error_code& ec) { bool const success = [&]() diff --git a/include/beast/websocket/stream.hpp b/include/beast/websocket/stream.hpp index 7f24278c..46dc70e1 100644 --- a/include/beast/websocket/stream.hpp +++ b/include/beast/websocket/stream.hpp @@ -28,7 +28,7 @@ namespace beast { namespace websocket { /// The type of object holding HTTP Upgrade requests -using request_type = http::request_header; +using request_type = http::header; /// The type of object holding HTTP Upgrade responses using response_type = @@ -2981,7 +2981,7 @@ private: Decorator const& decorator); void - do_response(http::response_header const& resp, + do_response(http::header const& resp, detail::sec_ws_key_type const& key, error_code& ec); }; diff --git a/test/http/message.cpp b/test/http/message.cpp index fb576748..737fced3 100644 --- a/test/http/message.cpp +++ b/test/http/message.cpp @@ -170,13 +170,13 @@ public: testHeaders() { { - using req_type = request_header; + using req_type = header; BOOST_STATIC_ASSERT(std::is_copy_constructible::value); BOOST_STATIC_ASSERT(std::is_move_constructible::value); BOOST_STATIC_ASSERT(std::is_copy_assignable::value); BOOST_STATIC_ASSERT(std::is_move_assignable::value); - using res_type = response_header; + using res_type = header; BOOST_STATIC_ASSERT(std::is_copy_constructible::value); BOOST_STATIC_ASSERT(std::is_move_constructible::value); BOOST_STATIC_ASSERT(std::is_copy_assignable::value); diff --git a/test/websocket/rfc6455.cpp b/test/websocket/rfc6455.cpp index 534a9cf9..905c435c 100644 --- a/test/websocket/rfc6455.cpp +++ b/test/websocket/rfc6455.cpp @@ -20,7 +20,7 @@ public: void test_is_upgrade() { - http::request_header req; + http::header req; req.version = 10; BEAST_EXPECT(! is_upgrade(req)); req.version = 11;