diff --git a/CHANGELOG.md b/CHANGELOG.md
index 590bee07..1a9bab60 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@ API Changes:
* auto_fragment is a member of stream
* binary, text are members of stream
+* read_buffer_size is a member of stream
Actions Required:
@@ -13,6 +14,9 @@ Actions Required:
* Change call sites which use message_type with set_option
to call stream::binary or stream::text instead.
+* Change call sites which use read_buffer_size with set_option to
+ call stream::read_buffer_size instead.
+
--------------------------------------------------------------------------------
Version 51
diff --git a/doc/quickref.xml b/doc/quickref.xml
index 61949345..77908a45 100644
--- a/doc/quickref.xml
+++ b/doc/quickref.xml
@@ -125,7 +125,6 @@
permessage_deflateping_callback
- read_buffer_sizeread_message_maxwrite_buffer_size
diff --git a/include/beast/websocket/option.hpp b/include/beast/websocket/option.hpp
index 181fd2b1..75ade538 100644
--- a/include/beast/websocket/option.hpp
+++ b/include/beast/websocket/option.hpp
@@ -124,47 +124,6 @@ struct ping_callback
};
#endif
-/** Read buffer size option.
-
- Sets the size of the read buffer used by the implementation to
- receive frames. The read buffer is needed when permessage-deflate
- is used.
-
- 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 read data.
-
- The default setting is 4096. The minimum value is 8.
-
- @note Objects of this type are used with
- @ref beast::websocket::stream::set_option.
-
- @par Example
- Setting the read buffer size.
- @code
- ...
- websocket::stream ws(ios);
- ws.set_option(read_buffer_size{16 * 1024});
- @endcode
-*/
-#if BEAST_DOXYGEN
-using read_buffer_size = implementation_defined;
-#else
-struct read_buffer_size
-{
- std::size_t value;
-
- explicit
- read_buffer_size(std::size_t n)
- : value(n)
- {
- if(n < 8)
- BOOST_THROW_EXCEPTION(std::invalid_argument{
- "read buffer size is too small"});
- }
-};
-#endif
-
/** Maximum incoming message size option.
Sets the largest permissible incoming message size. Message
diff --git a/include/beast/websocket/stream.hpp b/include/beast/websocket/stream.hpp
index ba04d38e..7a90f12f 100644
--- a/include/beast/websocket/stream.hpp
+++ b/include/beast/websocket/stream.hpp
@@ -263,15 +263,6 @@ public:
ping_cb_ = std::move(o.value);
}
- /// Set the read buffer size
- void
- set_option(read_buffer_size const& o)
- {
- rd_buf_size_ = o.value;
- // VFALCO What was the thinking here?
- //stream_.capacity(o.value);
- }
-
/// Set the maximum incoming message size allowed
void
set_option(read_message_max const& o)
@@ -331,6 +322,9 @@ public:
@code
ws.binary(true);
@endcode
+
+ @param v `true` if outgoing messages should indicate
+ binary, or `false` if they should indicate text.
*/
void
binary(bool v)
@@ -345,6 +339,44 @@ public:
return wr_opcode_ == opcode::binary;
}
+ /** Set the read buffer size option.
+
+ Sets the size of the read buffer used by the implementation to
+ receive frames. The read buffer is needed when permessage-deflate
+ is used.
+
+ 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 read data.
+
+ The default setting is 4096. The minimum value is 8.
+
+ @par Example
+ Setting the read buffer size.
+ @code
+ ws.read_buffer_size(16 * 1024);
+ @endcode
+
+ @param n The size of the read buffer.
+
+ @throw std::invalid_argument If the buffer size is less than 8.
+ */
+ void
+ read_buffer_size(std::size_t n)
+ {
+ if(n < 8)
+ BOOST_THROW_EXCEPTION(std::invalid_argument{
+ "read buffer size is too small"});
+ rd_buf_size_ = n;
+ }
+
+ /// Returns the read buffer size setting.
+ std::size_t
+ read_buffer_size() const
+ {
+ return rd_buf_size_;
+ }
+
/** Returns the close reason received from the peer.
This is only valid after a read completes with error::closed.
diff --git a/test/websocket/stream.cpp b/test/websocket/stream.cpp
index 89f35e22..88737c90 100644
--- a/test/websocket/stream.cpp
+++ b/test/websocket/stream.cpp
@@ -556,7 +556,7 @@ public:
ws.auto_fragment(true);
ws.set_option(write_buffer_size{2048});
ws.binary(false);
- ws.set_option(read_buffer_size{8192});
+ ws.read_buffer_size(8192);
ws.set_option(read_message_max{1 * 1024 * 1024});
try
{