Remove message free functions (API Change)

This commit is contained in:
Vinnie Falco
2017-07-20 08:12:18 -07:00
parent 3340666ad3
commit aa752e4dce
7 changed files with 11 additions and 76 deletions
+5 -33
View File
@@ -9,10 +9,10 @@
#define BEAST_HTTP_IMPL_MESSAGE_IPP
#include <beast/core/error.hpp>
#include <beast/http/rfc7230.hpp>
#include <beast/core/detail/ci_char_traits.hpp>
#include <beast/core/detail/type_traits.hpp>
#include <boost/assert.hpp>
#include <boost/throw_exception.hpp>
#include <stdexcept>
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<status>(v);
}
@@ -307,8 +307,8 @@ message<isRequest, Body, Fields>::
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 isRequest, class Fields>
bool
is_keep_alive(header<isRequest, Fields> 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 isRequest, class Fields>
bool
is_upgrade(header<isRequest, Fields> 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
-18
View File
@@ -595,24 +595,6 @@ swap(
message<isRequest, Body, Fields>& m1,
message<isRequest, Body, Fields>& m2);
//------------------------------------------------------------------------------
/** Returns `true` if the HTTP/1 message indicates a keep alive.
Undefined behavior if version is greater than 11.
*/
template<bool isRequest, class Fields>
bool
is_keep_alive(header<isRequest, Fields> 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 isRequest, class Fields>
bool
is_upgrade(header<isRequest, Fields> const& msg);
} // http
} // beast
+1 -1
View File
@@ -21,7 +21,7 @@ is_upgrade(http::header<true, Fields> 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;
+2 -1
View File
@@ -8,6 +8,7 @@
#ifndef BEAST_WEBSOCKET_IMPL_STREAM_IPP
#define BEAST_WEBSOCKET_IMPL_STREAM_IPP
#include <beast/websocket/rfc6455.hpp>
#include <beast/websocket/teardown.hpp>
#include <beast/websocket/detail/hybi13.hpp>
#include <beast/websocket/detail/pmd_extension.hpp>
@@ -285,7 +286,7 @@ do_response(http::header<false> 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;