From e690528132333484b143ff1f932609201ed3b48f Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Tue, 15 Aug 2017 16:59:17 -0700 Subject: [PATCH] Rename frame and header buffer types fix #736 --- CHANGELOG.md | 1 + .../boost/beast/websocket/detail/frame.hpp | 4 +-- include/boost/beast/websocket/impl/close.ipp | 4 +-- include/boost/beast/websocket/impl/fail.ipp | 7 +++--- include/boost/beast/websocket/impl/ping.ipp | 6 ++--- include/boost/beast/websocket/impl/read.ipp | 2 +- include/boost/beast/websocket/impl/write.ipp | 25 +++++++++++-------- include/boost/beast/websocket/stream.hpp | 4 +-- 8 files changed, 30 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dec4d633..696b202d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ WebSocket * Fix done state for WebSocket reads * Fix utf8 check for compressed frames +* Rename frame and header buffer types -------------------------------------------------------------------------------- diff --git a/include/boost/beast/websocket/detail/frame.hpp b/include/boost/beast/websocket/detail/frame.hpp index 19250143..0c203335 100644 --- a/include/boost/beast/websocket/detail/frame.hpp +++ b/include/boost/beast/websocket/detail/frame.hpp @@ -110,11 +110,11 @@ struct frame_header }; // holds the largest possible frame header -using fh_streambuf = +using fh_buffer = flat_static_buffer<14>; // holds the largest possible control frame -using frame_streambuf = +using frame_buffer = flat_static_buffer< 2 + 8 + 4 + 125 >; inline diff --git a/include/boost/beast/websocket/impl/close.ipp b/include/boost/beast/websocket/impl/close.ipp index 47f49e46..242e8f24 100644 --- a/include/boost/beast/websocket/impl/close.ipp +++ b/include/boost/beast/websocket/impl/close.ipp @@ -44,7 +44,7 @@ class stream::close_op { stream& ws; token tok; - detail::frame_streambuf fb; + detail::frame_buffer fb; state( Handler&, @@ -356,7 +356,7 @@ close(close_reason const& cr, error_code& ec) BOOST_ASSERT(! wr_close_); wr_close_ = true; { - detail::frame_streambuf fb; + detail::frame_buffer fb; write_close(fb, cr); boost::asio::write(stream_, fb.data(), ec); } diff --git a/include/boost/beast/websocket/impl/fail.ipp b/include/boost/beast/websocket/impl/fail.ipp index da0b4db9..723c2f65 100644 --- a/include/boost/beast/websocket/impl/fail.ipp +++ b/include/boost/beast/websocket/impl/fail.ipp @@ -42,7 +42,7 @@ class stream::fail_op struct state { stream& ws; - detail::frame_streambuf fb; + detail::frame_buffer fb; std::uint16_t code; error_code ev; token tok; @@ -222,8 +222,9 @@ do_fail( if(code != close_code::none && ! wr_close_) { wr_close_ = true; - detail::frame_streambuf fb; - write_close(fb, code); + detail::frame_buffer fb; + write_close< + flat_static_buffer_base>(fb, code); boost::asio::write(stream_, fb.data(), ec); failed_ = !!ec; if(failed_) diff --git a/include/boost/beast/websocket/impl/ping.ipp b/include/boost/beast/websocket/impl/ping.ipp index a4880bc9..a8b420c6 100644 --- a/include/boost/beast/websocket/impl/ping.ipp +++ b/include/boost/beast/websocket/impl/ping.ipp @@ -39,7 +39,7 @@ class stream::ping_op struct state { stream& ws; - detail::frame_streambuf fb; + detail::frame_buffer fb; token tok; state( @@ -205,7 +205,7 @@ ping(ping_data const& payload, error_code& ec) ec = boost::asio::error::operation_aborted; return; } - detail::frame_streambuf fb; + detail::frame_buffer fb; write_ping( fb, detail::opcode::ping, payload); boost::asio::write(stream_, fb.data(), ec); @@ -233,7 +233,7 @@ pong(ping_data const& payload, error_code& ec) ec = boost::asio::error::operation_aborted; return; } - detail::frame_streambuf fb; + detail::frame_buffer fb; write_ping( fb, detail::opcode::pong, payload); boost::asio::write(stream_, fb.data(), ec); diff --git a/include/boost/beast/websocket/impl/read.ipp b/include/boost/beast/websocket/impl/read.ipp index 47a8501f..8edf66ee 100644 --- a/include/boost/beast/websocket/impl/read.ipp +++ b/include/boost/beast/websocket/impl/read.ipp @@ -978,7 +978,7 @@ loop: } if(ctrl_cb_) ctrl_cb_(frame_type::ping, payload); - detail::frame_streambuf fb; + detail::frame_buffer fb; write_ping(fb, detail::opcode::pong, payload); boost::asio::write(stream_, fb.data(), ec); diff --git a/include/boost/beast/websocket/impl/write.ipp b/include/boost/beast/websocket/impl/write.ipp index 6d7d2817..f42755df 100644 --- a/include/boost/beast/websocket/impl/write.ipp +++ b/include/boost/beast/websocket/impl/write.ipp @@ -621,8 +621,9 @@ write_some(bool fin, } fh.fin = ! more; fh.len = n; - detail::fh_streambuf fh_buf; - detail::write(fh_buf, fh); + detail::fh_buffer fh_buf; + detail::write< + flat_static_buffer_base>(fh_buf, fh); wr_.cont = ! fin; boost::asio::write(stream_, buffer_cat(fh_buf.data(), b), ec); @@ -649,8 +650,9 @@ write_some(bool fin, // no mask, no autofrag fh.fin = fin; fh.len = remain; - detail::fh_streambuf fh_buf; - detail::write(fh_buf, fh); + detail::fh_buffer fh_buf; + detail::write< + flat_static_buffer_base>(fh_buf, fh); wr_.cont = ! fin; boost::asio::write(stream_, buffer_cat(fh_buf.data(), buffers), ec); @@ -670,8 +672,9 @@ write_some(bool fin, remain -= n; fh.len = n; fh.fin = fin ? remain == 0 : false; - detail::fh_streambuf fh_buf; - detail::write(fh_buf, fh); + detail::fh_buffer fh_buf; + detail::write< + flat_static_buffer_base>(fh_buf, fh); wr_.cont = ! fin; boost::asio::write(stream_, buffer_cat(fh_buf.data(), @@ -695,8 +698,9 @@ write_some(bool fin, fh.key = maskgen_(); detail::prepared_key key; detail::prepare_key(key, fh.key); - detail::fh_streambuf fh_buf; - detail::write(fh_buf, fh); + detail::fh_buffer fh_buf; + detail::write< + flat_static_buffer_base>(fh_buf, fh); consuming_buffers< ConstBufferSequence> cb{buffers}; { @@ -746,8 +750,9 @@ write_some(bool fin, remain -= n; fh.fin = fin ? remain == 0 : false; wr_.cont = ! fh.fin; - detail::fh_streambuf fh_buf; - detail::write(fh_buf, fh); + detail::fh_buffer fh_buf; + detail::write< + flat_static_buffer_base>(fh_buf, fh); boost::asio::write(stream_, buffer_cat(fh_buf.data(), b), ec); failed_ = !!ec; diff --git a/include/boost/beast/websocket/stream.hpp b/include/boost/beast/websocket/stream.hpp index 63639c8e..b242430b 100644 --- a/include/boost/beast/websocket/stream.hpp +++ b/include/boost/beast/websocket/stream.hpp @@ -154,7 +154,7 @@ class stream detail::prepared_key key; // current stateful mask key std::uint64_t size; // total size of current message so far std::uint64_t remain; // message frame bytes left in current frame - detail::frame_streambuf fb; // to write control frames (during reads) + detail::frame_buffer fb; // to write control frames (during reads) detail::utf8_checker utf8; // to validate utf8 // A small, circular buffer to read frame headers. @@ -201,7 +201,7 @@ class stream // sending a message. std::unique_ptr buf; - detail::fh_streambuf fb; + detail::fh_buffer fb; }; // State information for the permessage-deflate extension