From f7a0885d17576114f753d390d9d571f22909279b Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 1 May 2017 21:06:38 -0700 Subject: [PATCH] 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. --- CHANGELOG.md | 3 +- doc/quickref.xml | 1 - .../beast/websocket/detail/stream_base.hpp | 1 - include/beast/websocket/impl/stream.ipp | 10 +---- include/beast/websocket/option.hpp | 39 ------------------- include/beast/websocket/stream.hpp | 7 ---- test/websocket/stream.cpp | 2 - 7 files changed, 4 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23f1612e..6e7b8a5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ API Changes: -* Refactor WebSocket error codes (API Change) +* Refactor WebSocket error codes +* Remove websocket::keep_alive option -------------------------------------------------------------------------------- diff --git a/doc/quickref.xml b/doc/quickref.xml index e81e0eb5..208c3889 100644 --- a/doc/quickref.xml +++ b/doc/quickref.xml @@ -113,7 +113,6 @@ Options auto_fragment - keep_alive message_type permessage_deflate ping_callback diff --git a/include/beast/websocket/detail/stream_base.hpp b/include/beast/websocket/detail/stream_base.hpp index 1fa45d55..bde7eda7 100644 --- a/include/beast/websocket/detail/stream_base.hpp +++ b/include/beast/websocket/detail/stream_base.hpp @@ -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 diff --git a/include/beast/websocket/impl/stream.ipp b/include/beast/websocket/impl/stream.ipp index 3470c5db..135248e8 100644 --- a/include/beast/websocket/impl/stream.ipp +++ b/include/beast/websocket/impl/stream.ipp @@ -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; } diff --git a/include/beast/websocket/option.hpp b/include/beast/websocket/option.hpp index feba8912..6b265e4d 100644 --- a/include/beast/websocket/option.hpp +++ b/include/beast/websocket/option.hpp @@ -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 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 diff --git a/include/beast/websocket/stream.hpp b/include/beast/websocket/stream.hpp index c415563f..74b2e184 100644 --- a/include/beast/websocket/stream.hpp +++ b/include/beast/websocket/stream.hpp @@ -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) diff --git a/test/websocket/stream.cpp b/test/websocket/stream.cpp index 2bdbf33c..3da3d28d 100644 --- a/test/websocket/stream.cpp +++ b/test/websocket/stream.cpp @@ -541,7 +541,6 @@ public: { stream 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 ws(ios_, s.substr(i, s.size() - i)); - ws.set_option(keep_alive{true}); try { ws.accept(boost::asio::buffer(