//
-// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
+// Copyright (c) 2016-2019 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)
#include <boost/beast/http/status.hpp>
#include <boost/beast/http/type_traits.hpp>
#include <boost/beast/core/string.hpp>
-#include <boost/beast/core/detail/empty_base_optimization.hpp>
-#include <boost/beast/core/detail/integer_sequence.hpp>
+#include <boost/core/empty_value.hpp>
+#include <boost/mp11/integer_sequence.hpp>
#include <boost/assert.hpp>
#include <boost/optional.hpp>
#include <boost/throw_exception.hpp>
*/
#if BOOST_BEAST_DOXYGEN
template<bool isRequest, class Fields = fields>
-struct header : Fields
+class header : public Fields
#else
template<bool isRequest, class Fields = fields>
-struct header;
+class header;
template<class Fields>
-struct header<true, Fields> : Fields
+class header<true, Fields> : public Fields
#endif
{
+public:
static_assert(is_fields<Fields>::value,
- "Fields requirements not met");
+ "Fields type requirements not met");
/// Indicates if the header is a request or response.
#if BOOST_BEAST_DOXYGEN
@note This function is only available when `isRequest == true`.
- @see @ref method_string
+ @see method_string
*/
verb
method() const;
@note This function is only available when `isRequest == true`.
- @see @ref method
+ @see method
*/
string_view
method_string() const;
! std::is_convertible<typename
std::decay<Arg1>::type, verb>::value &&
! std::is_convertible<typename
- std::decay<Arg1>::type, header>::value
+ std::decay<Arg1>::type, status>::value
>::type>
explicit
header(Arg1&& arg1, ArgN&&... argn);
private:
template<bool, class, class>
- friend struct message;
+ friend class message;
template<class T>
friend
A `header` includes the start-line and header-fields.
*/
template<class Fields>
-struct header<false, Fields> : Fields
+class header<false, Fields> : public Fields
{
+public:
static_assert(is_fields<Fields>::value,
- "Fields requirements not met");
+ "Fields type requirements not met");
/// Indicates if the header is a request or response.
using is_request = std::false_type;
template<class Arg1, class... ArgN,
class = typename std::enable_if<
! std::is_convertible<typename
- std::decay<Arg1>::type, status>::value &&
+ std::decay<Arg1>::type, header>::value &&
+ ! std::is_convertible<typename
+ std::decay<Arg1>::type, verb>::value &&
! std::is_convertible<typename
- std::decay<Arg1>::type, header>::value
+ std::decay<Arg1>::type, status>::value
>::type>
explicit
header(Arg1&& arg1, ArgN&&... argn);
private:
#if ! BOOST_BEAST_DOXYGEN
template<bool, class, class>
- friend struct message;
+ friend class message;
template<class T>
friend
field value pairs.
*/
template<bool isRequest, class Body, class Fields = fields>
-struct message
- : header<isRequest, Fields>
+class message
+ : public header<isRequest, Fields>
#if ! BOOST_BEAST_DOXYGEN
- , beast::detail::empty_base_optimization<
+ , boost::empty_value<
typename Body::value_type>
#endif
{
+public:
/// The base class used to hold the header portion of the message.
using header_type = header<isRequest, Fields>;
/** Constructor
- @param method The request-method to use
+ @param method The request-method to use.
@param target The request-target.
- @param version The HTTP-version
+ @param version The HTTP-version.
@note This function is only available when `isRequest == true`.
*/
/** Constructor
- @param method The request-method to use
+ @param method The request-method to use.
@param target The request-target.
- @param version The HTTP-version
+ @param version The HTTP-version.
@param body_arg An argument forwarded to the `body` constructor.
/** Constructor
- @param method The request-method to use
+ @param method The request-method to use.
@param target The request-target.
- @param version The HTTP-version
+ @param version The HTTP-version.
@param body_arg An argument forwarded to the `body` constructor.
/** Constructor
- @param result The status-code for the response
+ @param result The status-code for the response.
- @param version The HTTP-version
+ @param version The HTTP-version.
@note This member is only available when `isRequest == false`.
*/
/** Constructor
- @param result The status-code for the response
+ @param result The status-code for the response.
- @param version The HTTP-version
+ @param version The HTTP-version.
@param body_arg An argument forwarded to the `body` constructor.
/** Constructor
- @param result The status-code for the response
+ @param result The status-code for the response.
- @param version The HTTP-version
+ @param version The HTTP-version.
@param body_arg An argument forwarded to the `body` constructor.
/** Set or clear the chunked Transfer-Encoding
- This function will set or removed the "chunked" transfer
+ This function will set or remove the "chunked" transfer
encoding as the last item in the list of encodings in the
field.
@li @ref chunked would return `true`
@li @ref result returns @ref status::no_content
-
+
@li @ref result returns @ref status::not_modified
@li @ref result returns any informational status class (100 to 199)
/** Returns the payload size of the body in octets if possible.
- This function invokes the @b Body algorithm to measure
+ This function invokes the <em>Body</em> algorithm to measure
the number of octets in the serialized body container. If
there is no body, this will return zero. Otherwise, if the
body exists but is not known ahead of time, `boost::none`
#endif
body()& noexcept
{
- return this->beast::detail::empty_base_optimization<
- typename Body::value_type>::member();
+ return this->boost::empty_value<
+ typename Body::value_type>::get();
}
/// Returns the body
body()&& noexcept
{
return std::move(
- this->beast::detail::empty_base_optimization<
- typename Body::value_type>::member());
+ this->boost::empty_value<
+ typename Body::value_type>::get());
}
/// Returns the body
#endif
body() const& noexcept
{
- return this->beast::detail::empty_base_optimization<
- typename Body::value_type>::member();
+ return this->boost::empty_value<
+ typename Body::value_type>::get();
}
private:
static_assert(is_body<Body>::value,
- "Body requirements not met");
+ "Body type requirements not met");
template<
class... BodyArgs,
message(
std::piecewise_construct_t,
std::tuple<BodyArgs...>& body_args,
- beast::detail::index_sequence<IBodyArgs...>)
- : beast::detail::empty_base_optimization<
- typename Body::value_type>(
+ mp11::index_sequence<IBodyArgs...>)
+ : boost::empty_value<
+ typename Body::value_type>(boost::empty_init_t(),
std::forward<BodyArgs>(
std::get<IBodyArgs>(body_args))...)
{
std::piecewise_construct_t,
std::tuple<BodyArgs...>& body_args,
std::tuple<FieldsArgs...>& fields_args,
- beast::detail::index_sequence<IBodyArgs...>,
- beast::detail::index_sequence<IFieldsArgs...>)
+ mp11::index_sequence<IBodyArgs...>,
+ mp11::index_sequence<IFieldsArgs...>)
: header_type(std::forward<FieldsArgs>(
std::get<IFieldsArgs>(fields_args))...)
- , beast::detail::empty_base_optimization<
- typename Body::value_type>(
+ , boost::empty_value<
+ typename Body::value_type>(boost::empty_init_t(),
std::forward<BodyArgs>(
std::get<IBodyArgs>(body_args))...)
{
} // beast
} // boost
-#include <boost/beast/http/impl/message.ipp>
+#include <boost/beast/http/impl/message.hpp>
#endif