Remove HTTP header aliases (API Change):

fix #382

* request_header and response_header are removed
This commit is contained in:
Vinnie Falco
2017-05-27 22:49:22 -07:00
parent d84713ece9
commit b9bdb1bbbc
9 changed files with 27 additions and 79 deletions

View File

@ -2,6 +2,10 @@ Version 46
* Add test::pipe * Add test::pipe
API Changes:
* Remove HTTP header aliases
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Version 45 Version 45

View File

@ -5,47 +5,6 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 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] [section:http Using HTTP]
[block ''' [block '''
@ -76,8 +35,6 @@ writing of messages and headers in the HTTP/1 wire format using Boost.Asio.
[section:message Message] [section:message Message]
The HTTP protocol defines the client and server roles: clients send messages 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 For notational convenience, these template type aliases are provided which
supply typical choices for the [*`Fields`] type: supply typical choices for the [*`Fields`] type:
``` ```
using request_header = header<true, fields>; /// A typical HTTP request
using response_header = header<false, fields>;
template<class Body, class Fields = fields> template<class Body, class Fields = fields>
using request = message<true, Body, Fields>; using request = message<true, Body, Fields>;
/// A typical HTTP response
template<class Body, class Fields = fields> template<class Body, class Fields = fields>
using response = message<false, Body, Fields>; using response = message<false, Body, Fields>;
``` ```
The code examples below show how to create and fill in a request and response The code examples below show how to create and fill in request and response
object: objects:
[table Create Message [table Create Message
[[HTTP Request] [HTTP Response]] [[HTTP Request] [HTTP Response]]
@ -181,14 +137,10 @@ results when serialized. Note that only the response has a body:
``` ```
]]] ]]]
[endsect] [endsect]
[section:fields Fields] [section:fields Fields]
The [*`Fields`] type represents a container that can set or retrieve the The [*`Fields`] type represents a container that can set or retrieve the

View File

@ -39,9 +39,7 @@
<member><link linkend="beast.ref.http__message">message</link></member> <member><link linkend="beast.ref.http__message">message</link></member>
<member><link linkend="beast.ref.http__message_parser">message_parser</link></member> <member><link linkend="beast.ref.http__message_parser">message_parser</link></member>
<member><link linkend="beast.ref.http__request">request</link></member> <member><link linkend="beast.ref.http__request">request</link></member>
<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">response</link></member>
<member><link linkend="beast.ref.http__response_header">response_header</link></member>
<member><link linkend="beast.ref.http__string_body">string_body</link></member> <member><link linkend="beast.ref.http__string_body">string_body</link></member>
</simplelist> </simplelist>
<bridgehead renderas="sect3">rfc7230</bridgehead> <bridgehead renderas="sect3">rfc7230</bridgehead>

View File

@ -20,7 +20,6 @@
namespace beast { namespace beast {
namespace http { namespace http {
#if BEAST_DOXYGEN
/** A container for a HTTP request or response header. /** A container for a HTTP request or response header.
A header includes the Start Line and Fields. A header includes the Start Line and Fields.
@ -33,11 +32,12 @@ namespace http {
@li Invoke algorithms which operate on the header only. @li Invoke algorithms which operate on the header only.
*/ */
template<bool isRequest, class Fields> #if BEAST_DOXYGEN
template<bool isRequest, class Fields = fields>
struct header struct header
#else #else
template<bool isRequest, class Fields> template<bool isRequest, class Fields = fields>
struct header; struct header;
template<class Fields> template<class Fields>
@ -285,7 +285,7 @@ struct header<false, Fields>
@tparam Fields The type of container used to hold the @tparam Fields The type of container used to hold the
field value pairs. field value pairs.
*/ */
template<bool isRequest, class Body, class Fields> template<bool isRequest, class Body, class Fields = fields>
struct message : header<isRequest, Fields> struct message : header<isRequest, Fields>
{ {
/// The base class used to hold the header portion of the message. /// The base class used to hold the header portion of the message.
@ -442,6 +442,14 @@ private:
} }
}; };
/// A typical HTTP request
template<class Body, class Fields = fields>
using request = message<true, Body, Fields>;
/// A typical HTTP response
template<class Body, class Fields = fields>
using response = message<false, Body, Fields>;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if BEAST_DOXYGEN #if BEAST_DOXYGEN
@ -468,20 +476,6 @@ swap(
message<isRequest, Body, Fields>& m1, message<isRequest, Body, Fields>& m1,
message<isRequest, Body, Fields>& m2); message<isRequest, Body, Fields>& m2);
/// A typical HTTP request header
using request_header = header<true, fields>;
/// Typical HTTP response header
using response_header = header<false, fields>;
/// A typical HTTP request
template<class Body, class Fields = fields>
using request = message<true, Body, Fields>;
/// A typical HTTP response
template<class Body, class Fields = fields>
using response = message<false, Body, Fields>;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** Returns `true` if the HTTP/1 message indicates a keep alive. /** Returns `true` if the HTTP/1 message indicates a keep alive.

View File

@ -39,7 +39,7 @@ class stream<NextLayer>::response_op
{ {
bool cont; bool cont;
stream<NextLayer>& ws; stream<NextLayer>& ws;
http::response_header res; http::header<false, http::fields> res;
int state = 0; int state = 0;
template<class Fields, class Decorator> template<class Fields, class Decorator>

View File

@ -282,7 +282,7 @@ build_response(request_type const& req,
template<class NextLayer> template<class NextLayer>
void void
stream<NextLayer>:: stream<NextLayer>::
do_response(http::response_header const& res, do_response(http::header<false> const& res,
detail::sec_ws_key_type const& key, error_code& ec) detail::sec_ws_key_type const& key, error_code& ec)
{ {
bool const success = [&]() bool const success = [&]()

View File

@ -28,7 +28,7 @@ namespace beast {
namespace websocket { namespace websocket {
/// The type of object holding HTTP Upgrade requests /// The type of object holding HTTP Upgrade requests
using request_type = http::request_header; using request_type = http::header<true, http::fields>;
/// The type of object holding HTTP Upgrade responses /// The type of object holding HTTP Upgrade responses
using response_type = using response_type =
@ -2981,7 +2981,7 @@ private:
Decorator const& decorator); Decorator const& decorator);
void void
do_response(http::response_header const& resp, do_response(http::header<false> const& resp,
detail::sec_ws_key_type const& key, error_code& ec); detail::sec_ws_key_type const& key, error_code& ec);
}; };

View File

@ -170,13 +170,13 @@ public:
testHeaders() testHeaders()
{ {
{ {
using req_type = request_header; using req_type = header<true>;
BOOST_STATIC_ASSERT(std::is_copy_constructible<req_type>::value); BOOST_STATIC_ASSERT(std::is_copy_constructible<req_type>::value);
BOOST_STATIC_ASSERT(std::is_move_constructible<req_type>::value); BOOST_STATIC_ASSERT(std::is_move_constructible<req_type>::value);
BOOST_STATIC_ASSERT(std::is_copy_assignable<req_type>::value); BOOST_STATIC_ASSERT(std::is_copy_assignable<req_type>::value);
BOOST_STATIC_ASSERT(std::is_move_assignable<req_type>::value); BOOST_STATIC_ASSERT(std::is_move_assignable<req_type>::value);
using res_type = response_header; using res_type = header<false>;
BOOST_STATIC_ASSERT(std::is_copy_constructible<res_type>::value); BOOST_STATIC_ASSERT(std::is_copy_constructible<res_type>::value);
BOOST_STATIC_ASSERT(std::is_move_constructible<res_type>::value); BOOST_STATIC_ASSERT(std::is_move_constructible<res_type>::value);
BOOST_STATIC_ASSERT(std::is_copy_assignable<res_type>::value); BOOST_STATIC_ASSERT(std::is_copy_assignable<res_type>::value);

View File

@ -20,7 +20,7 @@ public:
void void
test_is_upgrade() test_is_upgrade()
{ {
http::request_header req; http::header<true> req;
req.version = 10; req.version = 10;
BEAST_EXPECT(! is_upgrade(req)); BEAST_EXPECT(! is_upgrade(req));
req.version = 11; req.version = 11;