Files
boost_beast/include/beast/websocket/impl/rfc6455.ipp
T
Vinnie Falco ac175cb694 Refactor method and verb (API Change):
The verb interfaces now use verb::unknown instead of
boost::optional<verb> == boost::none to indicate that
the request-method is an unrecognized string.

The http::header interface is modified to focus more on the
verb enum rather than the string. For recognized verbs, the
implementation stores an integer instead of the string.
Unknown verbs are still stored as strings.

* header::method now returns a verb
* header::method_string returns the method text
2017-06-04 14:51:41 -07:00

37 lines
862 B
C++

//
// Copyright (c) 2013-2017 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)
//
#ifndef BEAST_WEBSOCKET_IMPL_RFC6455_IPP
#define BEAST_WEBSOCKET_IMPL_RFC6455_IPP
#include <beast/http/rfc7230.hpp>
namespace beast {
namespace websocket {
template<class Fields>
bool
is_upgrade(http::header<true, Fields> const& req)
{
if(req.version < 11)
return false;
if(req.method() != http::verb::get)
return false;
if(! http::is_upgrade(req))
return false;
if(! http::token_list{req.fields["Upgrade"]}.exists("websocket"))
return false;
if(! req.fields.exists("Sec-WebSocket-Version"))
return false;
return true;
}
} // websocket
} // beast
#endif