mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 14:54:32 +02:00
Remove websocket::keep_alive option (API Change):
fix #332 This removes the keep_alive option from the WebSocket stream. Callers who wish to control the behavior of the Connection header may do so in the decorator and completion handlers for the handshake and accept functions.
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
|
||||
API Changes:
|
||||
|
||||
* Refactor WebSocket error codes (API Change)
|
||||
* Refactor WebSocket error codes
|
||||
* Remove websocket::keep_alive option
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -113,7 +113,6 @@
|
||||
<bridgehead renderas="sect3">Options</bridgehead>
|
||||
<simplelist type="vert" columns="1">
|
||||
<member><link linkend="beast.ref.websocket__auto_fragment">auto_fragment</link></member>
|
||||
<member><link linkend="beast.ref.websocket__keep_alive">keep_alive</link></member>
|
||||
<member><link linkend="beast.ref.websocket__message_type">message_type</link></member>
|
||||
<member><link linkend="beast.ref.websocket__permessage_deflate">permessage_deflate</link></member>
|
||||
<member><link linkend="beast.ref.websocket__ping_callback">ping_callback</link></member>
|
||||
|
@@ -49,7 +49,6 @@ protected:
|
||||
struct op {};
|
||||
|
||||
detail::maskgen maskgen_; // source of mask keys
|
||||
bool keep_alive_ = false; // close on failed upgrade
|
||||
std::size_t rd_msg_max_ =
|
||||
16 * 1024 * 1024; // max message size
|
||||
bool wr_autofrag_ = true; // auto fragment
|
||||
|
@@ -218,10 +218,7 @@ build_response(request_type const& req,
|
||||
res.reason = http::reason_string(res.status);
|
||||
res.version = req.version;
|
||||
res.body = text;
|
||||
prepare(res,
|
||||
(is_keep_alive(req) && keep_alive_) ?
|
||||
http::connection::keep_alive :
|
||||
http::connection::close);
|
||||
prepare(res);
|
||||
decorate(res);
|
||||
return res;
|
||||
};
|
||||
@@ -252,10 +249,7 @@ build_response(request_type const& req,
|
||||
res.reason = http::reason_string(res.status);
|
||||
res.version = req.version;
|
||||
res.fields.insert("Sec-WebSocket-Version", "13");
|
||||
prepare(res,
|
||||
(is_keep_alive(req) && keep_alive_) ?
|
||||
http::connection::keep_alive :
|
||||
http::connection::close);
|
||||
prepare(res);
|
||||
decorate(res);
|
||||
return res;
|
||||
}
|
||||
|
@@ -58,45 +58,6 @@ struct auto_fragment
|
||||
};
|
||||
#endif
|
||||
|
||||
/** Keep-alive option.
|
||||
|
||||
Determines if the connection is closed after a failed upgrade
|
||||
request.
|
||||
|
||||
This setting only affects the behavior of HTTP requests that
|
||||
implicitly or explicitly ask for a keepalive. For HTTP requests
|
||||
that indicate the connection should be closed, the connection is
|
||||
closed as per rfc7230.
|
||||
|
||||
The default setting is to close connections after a failed
|
||||
upgrade request.
|
||||
|
||||
@note Objects of this type are used with
|
||||
@ref beast::websocket::stream::set_option.
|
||||
|
||||
@par Example
|
||||
Setting the keep alive option.
|
||||
@code
|
||||
...
|
||||
websocket::stream<ip::tcp::socket> ws(ios);
|
||||
ws.set_option(keep_alive{8192});
|
||||
@endcode
|
||||
*/
|
||||
#if BEAST_DOXYGEN
|
||||
using keep_alive = implementation_defined;
|
||||
#else
|
||||
struct keep_alive
|
||||
{
|
||||
bool value;
|
||||
|
||||
explicit
|
||||
keep_alive(bool v)
|
||||
: value(v)
|
||||
{
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/** Message type option.
|
||||
|
||||
This controls the opcode set for outgoing messages. Valid
|
||||
|
@@ -185,13 +185,6 @@ public:
|
||||
wr_autofrag_ = o.value;
|
||||
}
|
||||
|
||||
/// Set the keep-alive option
|
||||
void
|
||||
set_option(keep_alive const& o)
|
||||
{
|
||||
keep_alive_ = o.value;
|
||||
}
|
||||
|
||||
/// Set the outgoing message type
|
||||
void
|
||||
set_option(message_type const& o)
|
||||
|
@@ -541,7 +541,6 @@ public:
|
||||
{
|
||||
stream<socket_type> ws(ios_);
|
||||
ws.set_option(auto_fragment{true});
|
||||
ws.set_option(keep_alive{false});
|
||||
ws.set_option(write_buffer_size{2048});
|
||||
ws.set_option(message_type{opcode::text});
|
||||
ws.set_option(read_buffer_size{8192});
|
||||
@@ -992,7 +991,6 @@ public:
|
||||
{
|
||||
stream<test::string_istream> ws(ios_,
|
||||
s.substr(i, s.size() - i));
|
||||
ws.set_option(keep_alive{true});
|
||||
try
|
||||
{
|
||||
ws.accept(boost::asio::buffer(
|
||||
|
Reference in New Issue
Block a user