From c9908eada05305051875ae20e6a271d32e57b57b Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sat, 8 Jul 2017 17:11:49 -0700 Subject: [PATCH] Tidy up includes and javadocs --- include/beast/http.hpp | 1 + include/beast/http/buffer_body.hpp | 18 ++++++++++++----- include/beast/http/dynamic_body.hpp | 29 ++++++++++++++++++++++------ include/beast/http/empty_body.hpp | 30 ++++++++++++++++++++--------- test/http/empty_body.cpp | 10 ++++++++++ 5 files changed, 68 insertions(+), 20 deletions(-) diff --git a/include/beast/http.hpp b/include/beast/http.hpp index 5ebf1b7a..a7e8519e 100644 --- a/include/beast/http.hpp +++ b/include/beast/http.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/include/beast/http/buffer_body.hpp b/include/beast/http/buffer_body.hpp index 3b4f660a..61a99f17 100644 --- a/include/beast/http/buffer_body.hpp +++ b/include/beast/http/buffer_body.hpp @@ -19,10 +19,12 @@ namespace beast { namespace http { -/** A serializable body represented by caller provided buffers. +/** A @b Body using a caller provided buffer - This body type permits the use of @ref parser or @ref serializer - with caller provided buffers. + Messages using this body type may be serialized and parsed. + To use this class, the caller must initialize the members + of @ref buffer_body::value_type to appropriate values before + each call to read or write during a stream operation. */ struct buffer_body { @@ -86,8 +88,11 @@ struct buffer_body bool more = true; }; + /** The algorithm for serializing the body + + Meets the requirements of @b BodyReader. + */ #if BEAST_DOXYGEN - /// The algorithm to obtain buffers representing the body using reader = implementation_defined; #else class reader @@ -146,8 +151,11 @@ struct buffer_body }; #endif + /** The algorithm for parsing the body + + Meets the requirements of @b BodyReader. + */ #if BEAST_DOXYGEN - /// The algorithm used store buffers in this body using writer = implementation_defined; #else class writer diff --git a/include/beast/http/dynamic_body.hpp b/include/beast/http/dynamic_body.hpp index 35fbaddc..c5142084 100644 --- a/include/beast/http/dynamic_body.hpp +++ b/include/beast/http/dynamic_body.hpp @@ -20,9 +20,11 @@ namespace beast { namespace http { -/** An HTTP message body represented by a @b DynamicBuffer. +/** A @b Body using a @b DynamicBuffer - Meets the requirements of @b Body. + This body uses a @b DynamicBuffer as a memory-based container + for holding message payloads. Messages using this body type + may be serialized and parsed. */ template struct basic_dynamic_body @@ -30,10 +32,19 @@ struct basic_dynamic_body static_assert(is_dynamic_buffer::value, "DynamicBuffer requirements not met"); - /// The type of the body member when used in a message. + /** The type of container used for the body + + This determines the type of @ref message::body + when this body type is used with a message container. + */ using value_type = DynamicBuffer; - /// Returns the content length of this body in a message. + /** Returns the payload size of the body + + When this body is used with @ref message::prepare_payload, + the Content-Length will be set to the payload size, and + any chunked Transfer-Encoding will be removed. + */ static std::uint64_t size(value_type const& v) @@ -41,8 +52,11 @@ struct basic_dynamic_body return v.size(); } + /** The algorithm for serializing the body + + Meets the requirements of @b BodyReader. + */ #if BEAST_DOXYGEN - /// The algorithm to obtain buffers representing the body using reader = implementation_defined; #else class reader @@ -76,8 +90,11 @@ struct basic_dynamic_body }; #endif + /** The algorithm for parsing the body + + Meets the requirements of @b BodyReader. + */ #if BEAST_DOXYGEN - /// The algorithm used store buffers in this body using writer = implementation_defined; #else class writer diff --git a/include/beast/http/empty_body.hpp b/include/beast/http/empty_body.hpp index 9468502c..2db58a01 100644 --- a/include/beast/http/empty_body.hpp +++ b/include/beast/http/empty_body.hpp @@ -16,26 +16,32 @@ namespace beast { namespace http { -/** An empty message body. +/** An empty @b Body This body is used to represent messages which do not have a message body. If this body is used with a parser, and the parser encounters octets corresponding to a message body, the parser will fail with the error @ref http::unexpected_body. - Meets the requirements of @b Body. The Content-Length of this - body is always 0. + The Content-Length of this body is always 0. */ struct empty_body { - /// The type of the body member when used in a message. + /** The type of container used for the body + + This determines the type of @ref message::body + when this body type is used with a message container. + */ struct value_type { - // VFALCO We could stash boost::optional - // for the content length here, set on init() }; - /// Returns the content length of the body in a message. + /** Returns the payload size of the body + + When this body is used with @ref message::prepare_payload, + the Content-Length will be set to the payload size, and + any chunked Transfer-Encoding will be removed. + */ static std::uint64_t size(value_type) @@ -43,8 +49,11 @@ struct empty_body return 0; } + /** The algorithm for serializing the body + + Meets the requirements of @b BodyReader. + */ #if BEAST_DOXYGEN - /// The algorithm to obtain buffers representing the body using reader = implementation_defined; #else struct reader @@ -74,8 +83,11 @@ struct empty_body }; #endif + /** The algorithm for parsing the body + + Meets the requirements of @b BodyReader. + */ #if BEAST_DOXYGEN - /// The algorithm used store buffers in this body using writer = implementation_defined; #else struct writer diff --git a/test/http/empty_body.cpp b/test/http/empty_body.cpp index fa190ed3..a1fdfd5e 100644 --- a/test/http/empty_body.cpp +++ b/test/http/empty_body.cpp @@ -7,3 +7,13 @@ // Test that header file is self-contained. #include + +namespace beast { +namespace http { + +BOOST_STATIC_ASSERT(is_body::value); +BOOST_STATIC_ASSERT(is_body_reader::value); +BOOST_STATIC_ASSERT(is_body_writer::value); + +} // http +} // beast