rfc6455.hpp 1013 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #ifndef BOOST_BEAST_WEBSOCKET_IMPL_RFC6455_HPP
  10. #define BOOST_BEAST_WEBSOCKET_IMPL_RFC6455_HPP
  11. #include <boost/beast/http/fields.hpp>
  12. #include <boost/beast/http/rfc7230.hpp>
  13. namespace boost {
  14. namespace beast {
  15. namespace websocket {
  16. template<class Allocator>
  17. bool
  18. is_upgrade(http::header<true,
  19. http::basic_fields<Allocator>> const& req)
  20. {
  21. if(req.version() < 11)
  22. return false;
  23. if(req.method() != http::verb::get)
  24. return false;
  25. if(! http::token_list{req[http::field::connection]}.exists("upgrade"))
  26. return false;
  27. if(! http::token_list{req[http::field::upgrade]}.exists("websocket"))
  28. return false;
  29. return true;
  30. }
  31. } // websocket
  32. } // beast
  33. } // boost
  34. #endif