Files
beast/test/websocket/rfc6455.cpp
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

50 lines
1.2 KiB
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)
//
// Test that header file is self-contained.
#include <beast/websocket/rfc6455.hpp>
#include <beast/unit_test/suite.hpp>
namespace beast {
namespace websocket {
class rfc6455_test
: public beast::unit_test::suite
{
public:
void
test_is_upgrade()
{
http::request_header req;
req.version = 10;
BEAST_EXPECT(! is_upgrade(req));
req.version = 11;
req.method("POST");
req.target("/");
BEAST_EXPECT(! is_upgrade(req));
req.method("GET");
req.fields.insert("Connection", "upgrade");
BEAST_EXPECT(! is_upgrade(req));
req.fields.insert("Upgrade", "websocket");
BEAST_EXPECT(! is_upgrade(req));
req.fields.insert("Sec-WebSocket-Version", "13");
BEAST_EXPECT(is_upgrade(req));
}
void
run() override
{
test_is_upgrade();
}
};
BEAST_DEFINE_TESTSUITE(rfc6455,websocket,beast);
} // websocket
} // beast