forked from boostorg/beast
Tidy up tests, build scripts, and documentation:
* Concepts split up into individual files * Function definitions moved to .ipp files * Add more tests to fill gaps in coverage * Fix documentation Xsl
This commit is contained in:
1 parent
c309f53ed2
commit
313620ce7e
92 files changed
+2915
-1808
No files matched your search
@@ -17,10 +17,9 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_WSPROTO_DEBUG_H_INCLUDED
|
||||
#define BEAST_WSPROTO_DEBUG_H_INCLUDED
|
||||
#ifndef BEAST_WEBSOCKET_DETAIL_DEBUG_HPP
|
||||
#define BEAST_WEBSOCKET_DETAIL_DEBUG_HPP
|
||||
|
||||
#include <beast/unit_test/suite.h>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
@@ -82,7 +81,7 @@ format(std::string s)
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // wsproto
|
||||
} // websocket
|
||||
} // beast
|
||||
|
||||
#endif
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
const char*
|
||||
name() const noexcept override
|
||||
{
|
||||
return "wsproto";
|
||||
return "websocket";
|
||||
}
|
||||
|
||||
std::string
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
case error::request_invalid: return "upgrade request invalid";
|
||||
case error::request_denied: return "upgrade request denied";
|
||||
default:
|
||||
return "wsproto.error";
|
||||
return "websocket error";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define BEAST_WEBSOCKET_ERROR_HPP
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
|
||||
namespace beast {
|
||||
namespace websocket {
|
||||
@@ -16,7 +17,7 @@ namespace websocket {
|
||||
/// The type of error used by functions and completion handlers.
|
||||
using error_code = boost::system::error_code;
|
||||
|
||||
/// Error values
|
||||
/// Error codes returned from @ref stream operations.
|
||||
enum class error
|
||||
{
|
||||
/// Both sides performed a WebSocket close
|
||||
@@ -50,8 +51,10 @@ enum class error
|
||||
request_denied
|
||||
};
|
||||
|
||||
#if ! GENERATING_DOCS
|
||||
error_code
|
||||
make_error_code(error e);
|
||||
#endif
|
||||
|
||||
} // websocket
|
||||
} // beast
|
||||
|
||||
@@ -396,7 +396,7 @@ operator()(error_code ec,std::size_t bytes_transferred, bool again)
|
||||
// teardown
|
||||
case 11:
|
||||
d.state = 12;
|
||||
wsproto_helpers::call_async_teardown(
|
||||
websocket_helpers::call_async_teardown(
|
||||
d.ws.next_layer(), std::move(*this));
|
||||
return;
|
||||
|
||||
@@ -482,7 +482,7 @@ operator()(error_code ec,std::size_t bytes_transferred, bool again)
|
||||
// teardown
|
||||
case 19:
|
||||
d.state = 20;
|
||||
wsproto_helpers::call_async_teardown(
|
||||
websocket_helpers::call_async_teardown(
|
||||
d.ws.next_layer(), std::move(*this));
|
||||
return;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define BEAST_WEBSOCKET_IMPL_SSL_IPP_INCLUDED
|
||||
|
||||
#include <beast/async_completion.hpp>
|
||||
#include <beast/type_check.hpp>
|
||||
#include <beast/handler_concepts.hpp>
|
||||
|
||||
namespace beast {
|
||||
namespace websocket {
|
||||
@@ -144,7 +144,7 @@ async_teardown(
|
||||
boost::asio::ssl::stream<AsyncStream>& stream,
|
||||
TeardownHandler&& handler)
|
||||
{
|
||||
static_assert(beast::is_Handler<
|
||||
static_assert(beast::is_CompletionHandler<
|
||||
TeardownHandler, void(error_code)>::value,
|
||||
"TeardownHandler requirements not met");
|
||||
detail::teardown_ssl_op<AsyncStream, typename std::decay<
|
||||
|
||||
@@ -18,16 +18,17 @@
|
||||
#include <beast/websocket/impl/response_op.ipp>
|
||||
#include <beast/websocket/impl/write_op.ipp>
|
||||
#include <beast/websocket/impl/write_frame_op.ipp>
|
||||
#include <beast/buffer_cat.hpp>
|
||||
#include <beast/consuming_buffers.hpp>
|
||||
#include <beast/prepare_buffers.hpp>
|
||||
#include <beast/static_streambuf.hpp>
|
||||
#include <beast/streambuf.hpp>
|
||||
#include <beast/type_check.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <beast/http/reason.hpp>
|
||||
#include <beast/http/rfc2616.hpp>
|
||||
#include <beast/buffer_cat.hpp>
|
||||
#include <beast/buffer_concepts.hpp>
|
||||
#include <beast/consuming_buffers.hpp>
|
||||
#include <beast/prepare_buffers.hpp>
|
||||
#include <beast/static_streambuf.hpp>
|
||||
#include <beast/stream_concepts.hpp>
|
||||
#include <beast/streambuf.hpp>
|
||||
#include <boost/endian/buffers.hpp>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@@ -613,7 +614,7 @@ read_frame(frame_info& fi, Streambuf& streambuf, error_code& ec)
|
||||
if(error_)
|
||||
return;
|
||||
}
|
||||
wsproto_helpers::call_teardown(next_layer(), ec);
|
||||
websocket_helpers::call_teardown(next_layer(), ec);
|
||||
error_ = ec != 0;
|
||||
if(error_)
|
||||
return;
|
||||
@@ -622,7 +623,7 @@ read_frame(frame_info& fi, Streambuf& streambuf, error_code& ec)
|
||||
return;
|
||||
}
|
||||
if(! ec)
|
||||
wsproto_helpers::call_teardown(next_layer(), ec);
|
||||
websocket_helpers::call_teardown(next_layer(), ec);
|
||||
if(! ec)
|
||||
ec = error::closed;
|
||||
error_ = ec != 0;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define BEAST_WEBSOCKET_IMPL_TEARDOWN_IPP
|
||||
|
||||
#include <beast/async_completion.hpp>
|
||||
#include <beast/type_check.hpp>
|
||||
#include <beast/handler_concepts.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace beast {
|
||||
@@ -157,7 +157,7 @@ async_teardown(
|
||||
boost::asio::ip::tcp::socket& socket,
|
||||
TeardownHandler&& handler)
|
||||
{
|
||||
static_assert(beast::is_Handler<
|
||||
static_assert(beast::is_CompletionHandler<
|
||||
TeardownHandler, void(error_code)>::value,
|
||||
"TeardownHandler requirements not met");
|
||||
detail::teardown_tcp_op<typename std::decay<
|
||||
|
||||
@@ -19,17 +19,17 @@ namespace websocket {
|
||||
|
||||
/** Automatic fragmentation size option.
|
||||
|
||||
Sets the maximum size of fragments generated when sending
|
||||
messages on a WebSocket socket.
|
||||
Sets the maximum size of fragments generated when sending messages
|
||||
on a WebSocket stream.
|
||||
|
||||
When the automatic fragmentation size is non-zero, messages
|
||||
exceeding the size will be split into multiple frames no
|
||||
larger than the size. This setting does not affect frames
|
||||
send explicitly using `write_frame` or `async_write_frame`.
|
||||
When the automatic fragmentation size is non-zero, messages exceeding
|
||||
the size will be split into multiple frames no larger than the size.
|
||||
This setting does not affect frames sent explicitly using
|
||||
@ref stream::write_frame or @ref stream::async_write_frame.
|
||||
|
||||
The default setting is to fragment messages into 16KB frames.
|
||||
|
||||
@note Objects of this type are passed to socket::set_option.
|
||||
@note Objects of this type are passed to @ref stream::set_option.
|
||||
|
||||
@par Example
|
||||
Setting the automatic fragmentation size option:
|
||||
@@ -61,18 +61,20 @@ struct auto_fragment_size
|
||||
Server or User-Agent fields. The default setting applies no
|
||||
transformation to the HTTP message.
|
||||
|
||||
For synchronous operations, the implementation will call the
|
||||
decorator before the function call to perform the operation
|
||||
returns.
|
||||
The context in which the decorator is called depends on the
|
||||
type of operation performed:
|
||||
|
||||
For asynchronous operations, the implementation guarantees that
|
||||
calls to the decorator will be made from the same implicit or
|
||||
explicit strand used to call the asynchronous initiation
|
||||
@li For synchronous operations, the implementation will call the
|
||||
decorator before the operation unblocks.
|
||||
|
||||
@li For asynchronous operations, the implementation guarantees
|
||||
that calls to the decorator will be made from the same implicit
|
||||
or explicit strand used to call the asynchronous initiation
|
||||
function.
|
||||
|
||||
The default setting is no decorator.
|
||||
|
||||
@note Objects of this type are passed to socket::set_option.
|
||||
@note Objects of this type are passed to @ref stream::set_option.
|
||||
|
||||
@par Example
|
||||
Setting the decorator.
|
||||
@@ -121,7 +123,7 @@ decorate(Decorator&& d)
|
||||
The default setting is to close connections after a failed
|
||||
upgrade request.
|
||||
|
||||
@note Objects of this type are passed to socket::set_option.
|
||||
@note Objects of this type are passed to @ref stream::set_option.
|
||||
|
||||
@par Example
|
||||
Setting the keep alive option.
|
||||
@@ -155,7 +157,7 @@ struct keep_alive
|
||||
|
||||
The default setting is opcode::text.
|
||||
|
||||
@note Objects of this type are passed to socket::set_option.
|
||||
@note Objects of this type are passed to @ref stream::set_option.
|
||||
|
||||
@par Example
|
||||
Setting the message type to binary.
|
||||
@@ -191,7 +193,7 @@ struct message_type
|
||||
|
||||
The default is no buffering.
|
||||
|
||||
@note Objects of this type are passed to socket::set_option.
|
||||
@note Objects of this type are passed to @ref stream::set_option.
|
||||
|
||||
@par Example
|
||||
Setting the read buffer size.
|
||||
@@ -224,7 +226,7 @@ struct read_buffer_size
|
||||
|
||||
The default setting is 16 megabytes.
|
||||
|
||||
@note Objects of this type are passed to socket::set_option.
|
||||
@note Objects of this type are passed to @ref stream::set_option.
|
||||
|
||||
@par Example
|
||||
Setting the maximum read message size.
|
||||
@@ -262,7 +264,7 @@ struct read_message_max
|
||||
|
||||
The default setting is 4096. The minimum value is 1024.
|
||||
|
||||
@note Objects of this type are passed to socket::set_option.
|
||||
@note Objects of this type are passed to @ref stream::set_option.
|
||||
|
||||
@par Example
|
||||
Setting the write buffer size.
|
||||
|
||||
@@ -41,19 +41,24 @@ enum class opcode : std::uint8_t
|
||||
|
||||
These codes accompany close frames.
|
||||
|
||||
@see RFC 6455 7.4.1 Defined Status Codes
|
||||
https://tools.ietf.org/html/rfc6455#section-7.4.1
|
||||
@see <a href="https://tools.ietf.org/html/rfc6455#section-7.4.1">RFC 6455 7.4.1 Defined Status Codes</a>
|
||||
|
||||
*/
|
||||
#if GENERATING_DOCS
|
||||
enum close_code
|
||||
#else
|
||||
namespace close_code {
|
||||
using value = std::uint16_t;
|
||||
enum
|
||||
#endif
|
||||
{
|
||||
// used internally to mean "no error"
|
||||
/// used internally to mean "no error"
|
||||
none = 0,
|
||||
|
||||
normal = 1000,
|
||||
going_away = 1001,
|
||||
protocol_error = 1002,
|
||||
|
||||
unknown_data = 1003,
|
||||
bad_payload = 1007,
|
||||
policy_error = 1008,
|
||||
@@ -71,17 +76,15 @@ enum
|
||||
|
||||
last = 5000 // satisfy warnings
|
||||
};
|
||||
#if ! GENERATING_DOCS
|
||||
} // close_code
|
||||
#endif
|
||||
|
||||
#if ! GENERATING_DOCS
|
||||
|
||||
using reason_string_type =
|
||||
static_string<123, char>;
|
||||
|
||||
/// Payload type for pings and pongs
|
||||
using ping_payload_type =
|
||||
static_string<125, char>;
|
||||
|
||||
#endif
|
||||
|
||||
/** Description of the close reason.
|
||||
|
||||
@@ -25,14 +25,14 @@ namespace websocket {
|
||||
`boost::asio::ssl::stream`, callers are responsible for
|
||||
providing a suitable overload of this function.
|
||||
|
||||
@param socket The stream to tear down.
|
||||
@param stream The stream to tear down.
|
||||
|
||||
@param ec Set to the error if any occurred.
|
||||
*/
|
||||
template<class AsyncStream>
|
||||
template<class SyncStream>
|
||||
void
|
||||
teardown(
|
||||
boost::asio::ssl::stream<AsyncStream>& stream,
|
||||
boost::asio::ssl::stream<SyncStream>& stream,
|
||||
error_code& ec);
|
||||
|
||||
/** Start tearing down a `boost::asio::ssl::stream`.
|
||||
|
||||
+528
-243
File diff suppressed because it is too large.
Load diff
@@ -30,8 +30,8 @@ namespace websocket {
|
||||
/** Tear down a connection.
|
||||
|
||||
This tears down a connection. The implementation will call
|
||||
the overload of this function based on the `Stream` parameter
|
||||
used to consruct the socket. When `Stream` is a user defined
|
||||
the overload of this function based on the `Socket` parameter
|
||||
used to consruct the socket. When `Socket` is a user defined
|
||||
type, and not a `boost::asio::ip::tcp::socket` or any
|
||||
`boost::asio::ssl::stream`, callers are responsible for
|
||||
providing a suitable overload of this function.
|
||||
@@ -48,7 +48,7 @@ teardown(Socket& socket, error_code& ec) = delete;
|
||||
|
||||
This begins tearing down a connection asynchronously.
|
||||
The implementation will call the overload of this function
|
||||
based on the `Stream` parameter used to consruct the socket.
|
||||
based on the `Socket` parameter used to consruct the socket.
|
||||
When `Stream` is a user defined type, and not a
|
||||
`boost::asio::ip::tcp::socket` or any `boost::asio::ssl::stream`,
|
||||
callers are responsible for providing a suitable overload
|
||||
@@ -68,9 +68,9 @@ teardown(Socket& socket, error_code& ec) = delete;
|
||||
manner equivalent to using boost::asio::io_service::post().
|
||||
|
||||
*/
|
||||
template<class AsyncSocket, class TeardownHandler>
|
||||
template<class Socket, class TeardownHandler>
|
||||
void
|
||||
async_teardown(AsyncSocket& socket, TeardownHandler&& handler) = delete;
|
||||
async_teardown(Socket& socket, TeardownHandler&& handler) = delete;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -126,11 +126,11 @@ async_teardown(
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace wsproto_helpers {
|
||||
namespace websocket_helpers {
|
||||
|
||||
// Calls to teardown and async_teardown must be made from
|
||||
// a namespace that does not contain any overloads of these
|
||||
// functions. The wsproto_helpers namespace is defined here
|
||||
// functions. The websocket_helpers namespace is defined here
|
||||
// for that purpose.
|
||||
|
||||
template<class Socket>
|
||||
|
||||
Reference in new issue
Block a user