1 // 2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) 3 // 4 // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 // 7 // Official repository: https://github.com/boostorg/beast 8 // 9 10 #ifndef BOOST_BEAST_WEBSOCKET_IMPL_RFC6455_HPP 11 #define BOOST_BEAST_WEBSOCKET_IMPL_RFC6455_HPP 12 13 #include <boost/beast/http/fields.hpp> 14 #include <boost/beast/http/rfc7230.hpp> 15 16 namespace boost { 17 namespace beast { 18 namespace websocket { 19 20 template<class Allocator> 21 bool is_upgrade(http::header<true,http::basic_fields<Allocator>> const & req)22is_upgrade(http::header<true, 23 http::basic_fields<Allocator>> const& req) 24 { 25 if(req.version() < 11) 26 return false; 27 if(req.method() != http::verb::get) 28 return false; 29 if(! http::token_list{req[http::field::connection]}.exists("upgrade")) 30 return false; 31 if(! http::token_list{req[http::field::upgrade]}.exists("websocket")) 32 return false; 33 return true; 34 } 35 36 } // websocket 37 } // beast 38 } // boost 39 40 #endif 41