diff --git a/CHANGELOG.md b/CHANGELOG.md index eb6362c4..fd854c09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ API Changes: * Refactor prepare * Protect basic_fields special members * Remove message connection settings +* Remove message free functions -------------------------------------------------------------------------------- diff --git a/doc/quickref.xml b/doc/quickref.xml index 4e0e7e71..45362956 100644 --- a/doc/quickref.xml +++ b/doc/quickref.xml @@ -64,8 +64,7 @@ async_write async_write_header async_write_some - is_keep_alive - is_upgrade + int_to_status make_serializer obsolete_reason operator<< @@ -76,6 +75,7 @@ string_to_verb swap to_string + to_status_class write write_header write_some @@ -84,7 +84,6 @@ Constants - connection error field status diff --git a/include/beast/http/impl/message.ipp b/include/beast/http/impl/message.ipp index 6b28a746..acd05f1e 100644 --- a/include/beast/http/impl/message.ipp +++ b/include/beast/http/impl/message.ipp @@ -9,10 +9,10 @@ #define BEAST_HTTP_IMPL_MESSAGE_IPP #include -#include #include #include #include +#include #include namespace beast { @@ -43,7 +43,7 @@ method(verb v) { if(v == verb::unknown) BOOST_THROW_EXCEPTION( - std::invalid_argument{"unknown verb"}); + std::invalid_argument{"unknown method"}); method_ = v; this->set_method_impl({}); } @@ -140,7 +140,7 @@ result(unsigned v) if(v > 999) BOOST_THROW_EXCEPTION( std::invalid_argument{ - "invalid result-code"}); + "invalid status-code"}); result_ = static_cast(v); } @@ -307,8 +307,8 @@ message:: prepare(std::true_type) { auto const n = size(); - if(this->method_ == verb::trace && - (! n || *n > 0)) + if(this->method_ == verb::trace && ( + ! n || *n > 0)) BOOST_THROW_EXCEPTION(std::invalid_argument{ "invalid request body"}); if(n) @@ -366,34 +366,6 @@ swap( swap(m1.body, m2.body); } -template -bool -is_keep_alive(header const& msg) -{ - BOOST_ASSERT(msg.version == 10 || msg.version == 11); - if(msg.version == 11) - { - if(token_list{msg["Connection"]}.exists("close")) - return false; - return true; - } - if(token_list{msg["Connection"]}.exists("keep-alive")) - return true; - return false; -} - -template -bool -is_upgrade(header const& msg) -{ - BOOST_ASSERT(msg.version == 10 || msg.version == 11); - if(msg.version == 10) - return false; - if(token_list{msg["Connection"]}.exists("upgrade")) - return true; - return false; -} - } // http } // beast diff --git a/include/beast/http/message.hpp b/include/beast/http/message.hpp index 1942b5c0..b776f6b0 100644 --- a/include/beast/http/message.hpp +++ b/include/beast/http/message.hpp @@ -595,24 +595,6 @@ swap( message& m1, message& m2); -//------------------------------------------------------------------------------ - -/** Returns `true` if the HTTP/1 message indicates a keep alive. - - Undefined behavior if version is greater than 11. -*/ -template -bool -is_keep_alive(header const& msg); - -/** Returns `true` if the HTTP/1 message indicates an Upgrade request or response. - - Undefined behavior if version is greater than 11. -*/ -template -bool -is_upgrade(header const& msg); - } // http } // beast diff --git a/include/beast/websocket/impl/rfc6455.ipp b/include/beast/websocket/impl/rfc6455.ipp index 582d2dee..a1269ae1 100644 --- a/include/beast/websocket/impl/rfc6455.ipp +++ b/include/beast/websocket/impl/rfc6455.ipp @@ -21,7 +21,7 @@ is_upgrade(http::header const& req) return false; if(req.method() != http::verb::get) return false; - if(! http::is_upgrade(req)) + if(! http::token_list{req["Connection"]}.exists("upgrade")) return false; if(! http::token_list{req["Upgrade"]}.exists("websocket")) return false; diff --git a/include/beast/websocket/impl/stream.ipp b/include/beast/websocket/impl/stream.ipp index 2b5a4e82..74178fe9 100644 --- a/include/beast/websocket/impl/stream.ipp +++ b/include/beast/websocket/impl/stream.ipp @@ -8,6 +8,7 @@ #ifndef BEAST_WEBSOCKET_IMPL_STREAM_IPP #define BEAST_WEBSOCKET_IMPL_STREAM_IPP +#include #include #include #include @@ -285,7 +286,7 @@ do_response(http::header const& res, return false; if(res.result() != http::status::switching_protocols) return false; - if(! is_upgrade(res)) + if(! http::token_list{res["Connection"]}.exists("upgrade")) return false; if(! http::token_list{res["Upgrade"]}.exists("websocket")) return false; diff --git a/test/http/message.cpp b/test/http/message.cpp index 19355d06..32babbf4 100644 --- a/test/http/message.cpp +++ b/test/http/message.cpp @@ -194,25 +194,6 @@ public: } } - void - testFreeFunctions() - { - { - request m; - m.method(verb::get); - m.target("/"); - m.version = 11; - m.insert("Upgrade", "test"); - BEAST_EXPECT(! is_upgrade(m)); - - m.insert(field::connection, "upgrade"); - BEAST_EXPECT(is_upgrade(m)); - - m.version = 10; - BEAST_EXPECT(! is_upgrade(m)); - } - } - void testSwap() { @@ -312,7 +293,6 @@ public: { testMessage(); testHeaders(); - testFreeFunctions(); testSwap(); testSpecialMembers(); testMethod();