WebSocket refactoring and tests:

websocket:

* Move echo server to test/
* Fix warnings
* Fix maskgen being uncopyable
* Simplify utf8_checker special member declarations
* Fix stream move assignable when owning the next layer
* Add javadocs for stream special members
* Add stream unit tests
* Move throwing member definitions to the .ipp file
* Use get_lowest_layer in stream declaration
* Perform type checks at each call site instead of constructor
* Demote close_code to a non-class enum:
    Otherwise, application specific close codes
    cannot be assigned without using static_cast.

core:

* Add streambuf_readstream special members tests
* Add move assignment operator to streambuf_readstream
* Add detail/get_lowest_layer trait
* Add static_string tests
* Move static_string from websocket to core
This commit is contained in:
Vinnie Falco
2016-04-30 13:00:33 -04:00
parent 47dc31d8c2
commit 9390eb016c
38 changed files with 1792 additions and 567 deletions

View File

@@ -8,7 +8,7 @@
#ifndef BEAST_WEBSOCKET_RFC6455_HPP
#define BEAST_WEBSOCKET_RFC6455_HPP
#include <beast/websocket/static_string.hpp>
#include <beast/static_string.hpp>
#include <boost/optional.hpp>
#include <array>
#include <cstdint>
@@ -44,7 +44,9 @@ enum class opcode : std::uint8_t
@see RFC 6455 7.4.1 Defined Status Codes
https://tools.ietf.org/html/rfc6455#section-7.4.1
*/
enum class close_code : std::uint16_t
namespace close_code {
using value = std::uint16_t;
enum
{
// used internally to mean "no error"
none = 0,
@@ -69,6 +71,7 @@ enum class close_code : std::uint16_t
last = 5000 // satisfy warnings
};
} // close_code
#if ! GENERATING_DOCS
@@ -89,7 +92,7 @@ using ping_payload_type =
struct close_reason
{
/// The close code.
close_code code = close_code::none;
close_code::value code = close_code::none;
/// The optional utf8-encoded reason string.
reason_string_type reason;
@@ -102,7 +105,7 @@ struct close_reason
close_reason() = default;
/// Construct from a code.
close_reason(close_code code_)
close_reason(close_code::value code_)
: code(code_)
{
}
@@ -117,7 +120,7 @@ struct close_reason
/// Construct from a code and reason.
template<class CharT>
close_reason(close_code code_,
close_reason(close_code::value code_,
CharT const* reason_)
: code(code_)
, reason(reason_)