diff --git a/CHANGELOG.md b/CHANGELOG.md index 039ece6c..f86df04d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Version 200 * Tidy up multi_buffer * Refactor ostream * Refactor static_buffer +* HTTP tidying API Changes: diff --git a/include/boost/beast/http/chunk_encode.hpp b/include/boost/beast/http/chunk_encode.hpp index 168b83fe..f40ff77e 100644 --- a/include/boost/beast/http/chunk_encode.hpp +++ b/include/boost/beast/http/chunk_encode.hpp @@ -48,7 +48,7 @@ struct chunk_crlf #if BOOST_BEAST_DOXYGEN using value_type = __implementation_defined__; #else - using value_type = detail::chunk_crlf_iter::value_type; + using value_type = net::const_buffer; #endif /// Required for @b ConstBufferSequence @@ -61,7 +61,8 @@ struct chunk_crlf const_iterator begin() const { - return &detail::chunk_crlf_iter::value; + static net::const_buffer const cb{"\r\n", 2}; + return &cb; } /// Required for @b ConstBufferSequence diff --git a/include/boost/beast/http/detail/chunk_encode.hpp b/include/boost/beast/http/detail/chunk_encode.hpp index cdf7e1e8..e109bd5a 100644 --- a/include/boost/beast/http/detail/chunk_encode.hpp +++ b/include/boost/beast/http/detail/chunk_encode.hpp @@ -136,22 +136,25 @@ public: /// Returns a buffer sequence holding a CRLF for chunk encoding inline -net::const_buffer +net::const_buffer const& chunk_crlf() { - return {"\r\n", 2}; + static net::const_buffer const cb{"\r\n", 2}; + return cb; } /// Returns a buffer sequence holding a final chunk header inline -net::const_buffer +net::const_buffer const& chunk_last() { - return {"0\r\n", 3}; + static net::const_buffer const cb{"0\r\n", 3}; + return cb; } //------------------------------------------------------------------------------ +#if 0 template struct chunk_crlf_iter_type { @@ -176,44 +179,19 @@ typename chunk_crlf_iter_type::value_type chunk_crlf_iter_type::value; using chunk_crlf_iter = chunk_crlf_iter_type; +#endif //------------------------------------------------------------------------------ -template -struct chunk_size0_iter_type -{ - class value_type - { - char const s[3] = {'0', '\r', '\n'}; - - public: - value_type() = default; - - operator - net::const_buffer() const - { - return {s, sizeof(s)}; - } - }; - static value_type value; -}; - -template -typename chunk_size0_iter_type::value_type -chunk_size0_iter_type::value; - -using chunk_size0_iter = chunk_size0_iter_type; - struct chunk_size0 { - using value_type = chunk_size0_iter::value_type; - + using value_type = net::const_buffer; using const_iterator = value_type const*; const_iterator begin() const { - return &chunk_size0_iter::value; + return &chunk_last(); } const_iterator diff --git a/include/boost/beast/http/serializer.hpp b/include/boost/beast/http/serializer.hpp index 85222698..9b61a779 100644 --- a/include/boost/beast/http/serializer.hpp +++ b/include/boost/beast/http/serializer.hpp @@ -130,7 +130,7 @@ private: using cb4_t = buffers_suffix>; // crlf @@ -138,7 +138,7 @@ private: using cb5_t = buffers_suffix>; // crlf @@ -146,30 +146,30 @@ private: using cb6_t = buffers_suffix>; // crlf using pcb6_t = buffers_prefix_view; using cb7_t = buffers_suffix>; // crlf using pcb7_t = buffers_prefix_view; using cb8_t = buffers_suffix>; // crlf using pcb8_t = buffers_prefix_view;