Rename frame and header buffer types

fix #736
This commit is contained in:
Vinnie Falco
2017-08-15 16:59:17 -07:00
parent 3d6a009a96
commit e690528132
8 changed files with 30 additions and 23 deletions

View File

@@ -4,6 +4,7 @@ WebSocket
* Fix done state for WebSocket reads * Fix done state for WebSocket reads
* Fix utf8 check for compressed frames * Fix utf8 check for compressed frames
* Rename frame and header buffer types
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -110,11 +110,11 @@ struct frame_header
}; };
// holds the largest possible frame header // holds the largest possible frame header
using fh_streambuf = using fh_buffer =
flat_static_buffer<14>; flat_static_buffer<14>;
// holds the largest possible control frame // holds the largest possible control frame
using frame_streambuf = using frame_buffer =
flat_static_buffer< 2 + 8 + 4 + 125 >; flat_static_buffer< 2 + 8 + 4 + 125 >;
inline inline

View File

@@ -44,7 +44,7 @@ class stream<NextLayer>::close_op
{ {
stream<NextLayer>& ws; stream<NextLayer>& ws;
token tok; token tok;
detail::frame_streambuf fb; detail::frame_buffer fb;
state( state(
Handler&, Handler&,
@@ -356,7 +356,7 @@ close(close_reason const& cr, error_code& ec)
BOOST_ASSERT(! wr_close_); BOOST_ASSERT(! wr_close_);
wr_close_ = true; wr_close_ = true;
{ {
detail::frame_streambuf fb; detail::frame_buffer fb;
write_close<flat_static_buffer_base>(fb, cr); write_close<flat_static_buffer_base>(fb, cr);
boost::asio::write(stream_, fb.data(), ec); boost::asio::write(stream_, fb.data(), ec);
} }

View File

@@ -42,7 +42,7 @@ class stream<NextLayer>::fail_op
struct state struct state
{ {
stream<NextLayer>& ws; stream<NextLayer>& ws;
detail::frame_streambuf fb; detail::frame_buffer fb;
std::uint16_t code; std::uint16_t code;
error_code ev; error_code ev;
token tok; token tok;
@@ -222,8 +222,9 @@ do_fail(
if(code != close_code::none && ! wr_close_) if(code != close_code::none && ! wr_close_)
{ {
wr_close_ = true; wr_close_ = true;
detail::frame_streambuf fb; detail::frame_buffer fb;
write_close<flat_static_buffer_base>(fb, code); write_close<
flat_static_buffer_base>(fb, code);
boost::asio::write(stream_, fb.data(), ec); boost::asio::write(stream_, fb.data(), ec);
failed_ = !!ec; failed_ = !!ec;
if(failed_) if(failed_)

View File

@@ -39,7 +39,7 @@ class stream<NextLayer>::ping_op
struct state struct state
{ {
stream<NextLayer>& ws; stream<NextLayer>& ws;
detail::frame_streambuf fb; detail::frame_buffer fb;
token tok; token tok;
state( state(
@@ -205,7 +205,7 @@ ping(ping_data const& payload, error_code& ec)
ec = boost::asio::error::operation_aborted; ec = boost::asio::error::operation_aborted;
return; return;
} }
detail::frame_streambuf fb; detail::frame_buffer fb;
write_ping<flat_static_buffer_base>( write_ping<flat_static_buffer_base>(
fb, detail::opcode::ping, payload); fb, detail::opcode::ping, payload);
boost::asio::write(stream_, fb.data(), ec); 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; ec = boost::asio::error::operation_aborted;
return; return;
} }
detail::frame_streambuf fb; detail::frame_buffer fb;
write_ping<flat_static_buffer_base>( write_ping<flat_static_buffer_base>(
fb, detail::opcode::pong, payload); fb, detail::opcode::pong, payload);
boost::asio::write(stream_, fb.data(), ec); boost::asio::write(stream_, fb.data(), ec);

View File

@@ -978,7 +978,7 @@ loop:
} }
if(ctrl_cb_) if(ctrl_cb_)
ctrl_cb_(frame_type::ping, payload); ctrl_cb_(frame_type::ping, payload);
detail::frame_streambuf fb; detail::frame_buffer fb;
write_ping<flat_static_buffer_base>(fb, write_ping<flat_static_buffer_base>(fb,
detail::opcode::pong, payload); detail::opcode::pong, payload);
boost::asio::write(stream_, fb.data(), ec); boost::asio::write(stream_, fb.data(), ec);

View File

@@ -621,8 +621,9 @@ write_some(bool fin,
} }
fh.fin = ! more; fh.fin = ! more;
fh.len = n; fh.len = n;
detail::fh_streambuf fh_buf; detail::fh_buffer fh_buf;
detail::write<flat_static_buffer_base>(fh_buf, fh); detail::write<
flat_static_buffer_base>(fh_buf, fh);
wr_.cont = ! fin; wr_.cont = ! fin;
boost::asio::write(stream_, boost::asio::write(stream_,
buffer_cat(fh_buf.data(), b), ec); buffer_cat(fh_buf.data(), b), ec);
@@ -649,8 +650,9 @@ write_some(bool fin,
// no mask, no autofrag // no mask, no autofrag
fh.fin = fin; fh.fin = fin;
fh.len = remain; fh.len = remain;
detail::fh_streambuf fh_buf; detail::fh_buffer fh_buf;
detail::write<flat_static_buffer_base>(fh_buf, fh); detail::write<
flat_static_buffer_base>(fh_buf, fh);
wr_.cont = ! fin; wr_.cont = ! fin;
boost::asio::write(stream_, boost::asio::write(stream_,
buffer_cat(fh_buf.data(), buffers), ec); buffer_cat(fh_buf.data(), buffers), ec);
@@ -670,8 +672,9 @@ write_some(bool fin,
remain -= n; remain -= n;
fh.len = n; fh.len = n;
fh.fin = fin ? remain == 0 : false; fh.fin = fin ? remain == 0 : false;
detail::fh_streambuf fh_buf; detail::fh_buffer fh_buf;
detail::write<flat_static_buffer_base>(fh_buf, fh); detail::write<
flat_static_buffer_base>(fh_buf, fh);
wr_.cont = ! fin; wr_.cont = ! fin;
boost::asio::write(stream_, boost::asio::write(stream_,
buffer_cat(fh_buf.data(), buffer_cat(fh_buf.data(),
@@ -695,8 +698,9 @@ write_some(bool fin,
fh.key = maskgen_(); fh.key = maskgen_();
detail::prepared_key key; detail::prepared_key key;
detail::prepare_key(key, fh.key); detail::prepare_key(key, fh.key);
detail::fh_streambuf fh_buf; detail::fh_buffer fh_buf;
detail::write<flat_static_buffer_base>(fh_buf, fh); detail::write<
flat_static_buffer_base>(fh_buf, fh);
consuming_buffers< consuming_buffers<
ConstBufferSequence> cb{buffers}; ConstBufferSequence> cb{buffers};
{ {
@@ -746,8 +750,9 @@ write_some(bool fin,
remain -= n; remain -= n;
fh.fin = fin ? remain == 0 : false; fh.fin = fin ? remain == 0 : false;
wr_.cont = ! fh.fin; wr_.cont = ! fh.fin;
detail::fh_streambuf fh_buf; detail::fh_buffer fh_buf;
detail::write<flat_static_buffer_base>(fh_buf, fh); detail::write<
flat_static_buffer_base>(fh_buf, fh);
boost::asio::write(stream_, boost::asio::write(stream_,
buffer_cat(fh_buf.data(), b), ec); buffer_cat(fh_buf.data(), b), ec);
failed_ = !!ec; failed_ = !!ec;

View File

@@ -154,7 +154,7 @@ class stream
detail::prepared_key key; // current stateful mask key detail::prepared_key key; // current stateful mask key
std::uint64_t size; // total size of current message so far std::uint64_t size; // total size of current message so far
std::uint64_t remain; // message frame bytes left in current frame 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 detail::utf8_checker utf8; // to validate utf8
// A small, circular buffer to read frame headers. // A small, circular buffer to read frame headers.
@@ -201,7 +201,7 @@ class stream
// sending a message. // sending a message.
std::unique_ptr<std::uint8_t[]> buf; std::unique_ptr<std::uint8_t[]> buf;
detail::fh_streambuf fb; detail::fh_buffer fb;
}; };
// State information for the permessage-deflate extension // State information for the permessage-deflate extension