Files
beast/test/websocket/rfc6455.cpp
Vinnie Falco f7211da154 Refactor treatment of request-method (API Change):
fix #397

method enum class is added to represent all known request methods.
Functions are provided to convert from strings to and from the method
enumeration.

The fields container is modified to also work with the enum.
2017-07-20 08:12:17 -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::header<true> req;
req.version = 10;
BEAST_EXPECT(! is_upgrade(req));
req.version = 11;
req.method(http::verb::post);
req.target("/");
BEAST_EXPECT(! is_upgrade(req));
req.method(http::verb::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