diff --git a/CHANGELOG.md b/CHANGELOG.md
index f5462e26..bb492849 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,10 @@
* Make value optional in param-list
* Frame processing routines are member functions
+API Changes:
+
+* Rename mask_buffer_size to write_buffer_size
+
--------------------------------------------------------------------------------
1.0.0-b15
diff --git a/doc/quickref.xml b/doc/quickref.xml
index 2b070f6b..ebbb51be 100644
--- a/doc/quickref.xml
+++ b/doc/quickref.xml
@@ -94,11 +94,11 @@
auto_fragment_size
decorate
keep_alive
- mask_buffer_size
message_type
pong_callback
read_buffer_size
read_message_max
+ write_buffer_size
diff --git a/include/beast/websocket/detail/stream_base.hpp b/include/beast/websocket/detail/stream_base.hpp
index a2867fe9..85431f4d 100644
--- a/include/beast/websocket/detail/stream_base.hpp
+++ b/include/beast/websocket/detail/stream_base.hpp
@@ -77,7 +77,7 @@ protected:
16 * 1024 * 1024; // max message size
std::size_t
wr_frag_size_ = 16 * 1024; // size of auto-fragments
- std::size_t mask_buf_size_ = 4096; // mask buffer size
+ std::size_t wr_buf_size_ = 4096; // mask buffer size
opcode wr_opcode_ = opcode::text; // outgoing message type
pong_cb pong_cb_; // pong callback
role_type role_; // server or client
diff --git a/include/beast/websocket/impl/stream.ipp b/include/beast/websocket/impl/stream.ipp
index 7ba1a62c..b717ea88 100644
--- a/include/beast/websocket/impl/stream.ipp
+++ b/include/beast/websocket/impl/stream.ipp
@@ -695,7 +695,7 @@ write_frame(bool fin, ConstBufferSequence const& bs, error_code& ec)
detail::prepared_key_type key;
detail::prepare_key(key, fh.key);
auto const tmp_size =
- detail::clamp(fh.len, mask_buf_size_);
+ detail::clamp(fh.len, wr_buf_size_);
std::unique_ptr up(
new std::uint8_t[tmp_size]);
std::uint64_t remain = fh.len;
diff --git a/include/beast/websocket/impl/write_frame_op.ipp b/include/beast/websocket/impl/write_frame_op.ipp
index 2bbf250d..c9991eda 100644
--- a/include/beast/websocket/impl/write_frame_op.ipp
+++ b/include/beast/websocket/impl/write_frame_op.ipp
@@ -67,7 +67,7 @@ class stream::write_frame_op
fh.key = ws.maskgen_();
detail::prepare_key(key, fh.key);
tmp_size = detail::clamp(
- fh.len, ws.mask_buf_size_);
+ fh.len, ws.wr_buf_size_);
tmp = boost_asio_handler_alloc_helpers::
allocate(tmp_size, h);
remain = fh.len;
diff --git a/include/beast/websocket/option.hpp b/include/beast/websocket/option.hpp
index abe22409..4a4feecd 100644
--- a/include/beast/websocket/option.hpp
+++ b/include/beast/websocket/option.hpp
@@ -149,45 +149,6 @@ struct keep_alive
};
#endif
-/** Mask buffer size option.
-
- Sets the size of the buffer allocated when the implementation
- must allocate memory to apply the mask to a payload. Only affects
- streams operating in the client role, since only clients send
- masked frames. Lowering the size of the buffer can decrease the
- memory requirements for each connection, while increasing the size
- of the buffer can reduce the number of calls made to the next
- layer to write masked data.
-
- The default setting is 4096. The minimum value is 1.
-
- @note Objects of this type are passed to @ref stream::set_option.
-
- @par Example
- Setting the write buffer size.
- @code
- ...
- websocket::stream ws(ios);
- ws.set_option(mask_buffer_size{8192});
- @endcode
-*/
-#if GENERATING_DOCS
-using mask_buffer_size = implementation_defined;
-#else
-struct mask_buffer_size
-{
- std::size_t value;
-
- explicit
- mask_buffer_size(std::size_t n)
- : value(n)
- {
- if(n == 0)
- throw std::domain_error("invalid mask buffer size");
- }
-};
-#endif
-
/** Message type option.
This controls the opcode set for outgoing messages. Valid
@@ -337,6 +298,46 @@ struct read_message_max
};
#endif
+/** Write buffer size option.
+
+ Sets the size of the write buffer used by the implementation to
+ send frames. The write buffer is needed when masking payload data
+ in the client role, compressing frames, or auto-fragmenting message
+ data.
+
+ Lowering the size of the buffer can decrease the memory requirements
+ for each connection, while increasing the size of the buffer can reduce
+ the number of calls made to the next layer to write data.
+
+ The default setting is 4096. The minimum value is 64.
+
+ @note Objects of this type are passed to @ref stream::set_option.
+
+ @par Example
+ Setting the write buffer size.
+ @code
+ ...
+ websocket::stream ws(ios);
+ ws.set_option(write_buffer_size{8192});
+ @endcode
+*/
+#if GENERATING_DOCS
+using write_buffer_size = implementation_defined;
+#else
+struct write_buffer_size
+{
+ std::size_t value;
+
+ explicit
+ write_buffer_size(std::size_t n)
+ : value(n)
+ {
+ if(n < 64)
+ throw std::domain_error("write buffer size is too small");
+ }
+};
+#endif
+
} // websocket
} // beast
diff --git a/include/beast/websocket/stream.hpp b/include/beast/websocket/stream.hpp
index f200621f..a35308f1 100644
--- a/include/beast/websocket/stream.hpp
+++ b/include/beast/websocket/stream.hpp
@@ -241,9 +241,9 @@ public:
/// Set the size of the mask buffer
void
- set_option(mask_buffer_size const& o)
+ set_option(write_buffer_size const& o)
{
- mask_buf_size_ = o.value;
+ wr_buf_size_ = o.value;
stream_.capacity(o.value);
}
diff --git a/test/websocket/stream.cpp b/test/websocket/stream.cpp
index 76aaecc4..bab5a8c7 100644
--- a/test/websocket/stream.cpp
+++ b/test/websocket/stream.cpp
@@ -152,13 +152,13 @@ public:
ws.set_option(auto_fragment_size{2048});
ws.set_option(decorate(identity{}));
ws.set_option(keep_alive{false});
- ws.set_option(mask_buffer_size(2048));
+ ws.set_option(write_buffer_size{2048});
ws.set_option(message_type{opcode::text});
- ws.set_option(read_buffer_size(8192));
- ws.set_option(read_message_max(1 * 1024 * 1024));
+ ws.set_option(read_buffer_size{8192});
+ ws.set_option(read_message_max{1 * 1024 * 1024});
try
{
- ws.set_option(mask_buffer_size(0));
+ ws.set_option(write_buffer_size{0});
fail();
}
catch(std::exception const&)
@@ -925,7 +925,7 @@ public:
// send message with write buffer limit
{
std::string s(2000, '*');
- ws.set_option(mask_buffer_size(1200));
+ ws.set_option(write_buffer_size(1200));
ws.write(buffer(s.data(), s.size()));
{
// receive echoed message
@@ -1187,7 +1187,7 @@ public:
// send message with mask buffer limit
{
std::string s(2000, '*');
- ws.set_option(mask_buffer_size(1200));
+ ws.set_option(write_buffer_size(1200));
ws.async_write(buffer(s.data(), s.size()), do_yield[ec]);
if(ec)
throw system_error{ec};