Files
boost_beast/include/beast/websocket/impl/rfc6455.ipp
T
Vinnie Falco ff5e659545 Refactor http::header contents (API Change):
fix #124

The http::header data members "method", "url", and "reason"
are changed from data members, to pairs of get and set
functions which forward the call to the Fields type used
to instantiate the template.

Previously, these data members were implemented using
std::string. With this change, the implementation of the
Fields type used to instantiate the template is now in
control of the representation of those values. This permits
custom memory allocation strategies including uniform use of
the Allocator type already provided to beast::http::basic_fields.
2017-05-07 13:40:04 -07:00

37 lines
852 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() != "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