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:
Vinnie Falco
2017-05-01 21:06:38 -07:00
parent 3da0d8b6a9
commit f7a0885d17
7 changed files with 4 additions and 59 deletions

View File

@@ -10,7 +10,8 @@
API Changes: API Changes:
* Refactor WebSocket error codes (API Change) * Refactor WebSocket error codes
* Remove websocket::keep_alive option
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -113,7 +113,6 @@
<bridgehead renderas="sect3">Options</bridgehead> <bridgehead renderas="sect3">Options</bridgehead>
<simplelist type="vert" columns="1"> <simplelist type="vert" columns="1">
<member><link linkend="beast.ref.websocket__auto_fragment">auto_fragment</link></member> <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__message_type">message_type</link></member>
<member><link linkend="beast.ref.websocket__permessage_deflate">permessage_deflate</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> <member><link linkend="beast.ref.websocket__ping_callback">ping_callback</link></member>

View File

@@ -49,7 +49,6 @@ protected:
struct op {}; struct op {};
detail::maskgen maskgen_; // source of mask keys detail::maskgen maskgen_; // source of mask keys
bool keep_alive_ = false; // close on failed upgrade
std::size_t rd_msg_max_ = std::size_t rd_msg_max_ =
16 * 1024 * 1024; // max message size 16 * 1024 * 1024; // max message size
bool wr_autofrag_ = true; // auto fragment bool wr_autofrag_ = true; // auto fragment

View File

@@ -218,10 +218,7 @@ build_response(request_type const& req,
res.reason = http::reason_string(res.status); res.reason = http::reason_string(res.status);
res.version = req.version; res.version = req.version;
res.body = text; res.body = text;
prepare(res, prepare(res);
(is_keep_alive(req) && keep_alive_) ?
http::connection::keep_alive :
http::connection::close);
decorate(res); decorate(res);
return res; return res;
}; };
@@ -252,10 +249,7 @@ build_response(request_type const& req,
res.reason = http::reason_string(res.status); res.reason = http::reason_string(res.status);
res.version = req.version; res.version = req.version;
res.fields.insert("Sec-WebSocket-Version", "13"); res.fields.insert("Sec-WebSocket-Version", "13");
prepare(res, prepare(res);
(is_keep_alive(req) && keep_alive_) ?
http::connection::keep_alive :
http::connection::close);
decorate(res); decorate(res);
return res; return res;
} }

View File

@@ -58,45 +58,6 @@ struct auto_fragment
}; };
#endif #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. /** Message type option.
This controls the opcode set for outgoing messages. Valid This controls the opcode set for outgoing messages. Valid

View File

@@ -185,13 +185,6 @@ public:
wr_autofrag_ = o.value; 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 /// Set the outgoing message type
void void
set_option(message_type const& o) set_option(message_type const& o)

View File

@@ -541,7 +541,6 @@ public:
{ {
stream<socket_type> ws(ios_); stream<socket_type> ws(ios_);
ws.set_option(auto_fragment{true}); ws.set_option(auto_fragment{true});
ws.set_option(keep_alive{false});
ws.set_option(write_buffer_size{2048}); ws.set_option(write_buffer_size{2048});
ws.set_option(message_type{opcode::text}); ws.set_option(message_type{opcode::text});
ws.set_option(read_buffer_size{8192}); ws.set_option(read_buffer_size{8192});
@@ -992,7 +991,6 @@ public:
{ {
stream<test::string_istream> ws(ios_, stream<test::string_istream> ws(ios_,
s.substr(i, s.size() - i)); s.substr(i, s.size() - i));
ws.set_option(keep_alive{true});
try try
{ {
ws.accept(boost::asio::buffer( ws.accept(boost::asio::buffer(