read_message_max is a member of stream (API Change):

fix #446

* The read_message_max option struct is removed.

Actions Required:

* Change call sites which use read_message_max with set_option to
  call stream::read_message_max instead.
This commit is contained in:
Vinnie Falco
2017-06-08 18:22:25 -07:00
parent 513a54835c
commit b9dbb76c4f
6 changed files with 38 additions and 47 deletions

View File

@@ -5,6 +5,7 @@ API Changes:
* auto_fragment is a member of stream
* binary, text are members of stream
* read_buffer_size is a member of stream
* read_message_max is a member of stream
Actions Required:
@@ -17,6 +18,9 @@ Actions Required:
* Change call sites which use read_buffer_size with set_option to
call stream::read_buffer_size instead.
* Change call sites which use read_message_max with set_option to
call stream::read_message_max instead.
--------------------------------------------------------------------------------
Version 51

View File

@@ -125,7 +125,6 @@
<simplelist type="vert" columns="1">
<member><link linkend="beast.ref.websocket__permessage_deflate">permessage_deflate</link></member>
<member><link linkend="beast.ref.websocket__ping_callback">ping_callback</link></member>
<member><link linkend="beast.ref.websocket__read_message_max">read_message_max</link></member>
<member><link linkend="beast.ref.websocket__write_buffer_size">write_buffer_size</link></member>
</simplelist>
<bridgehead renderas="sect3">Constants</bridgehead>

View File

@@ -44,7 +44,7 @@ public:
{
ws.auto_fragment(false);
ws.set_option(pmd_);
ws.set_option(beast::websocket::read_message_max{64 * 1024 * 1024});
ws.read_message_max(64 * 1024 * 1024);
}
};

View File

@@ -124,41 +124,6 @@ struct ping_callback
};
#endif
/** Maximum incoming message size option.
Sets the largest permissible incoming message size. Message
frame fields indicating a size that would bring the total
message size over this limit will cause a protocol failure.
The default setting is 16 megabytes. A value of zero indicates
a limit of the maximum value of a `std::uint64_t`.
@note Objects of this type are used with
@ref beast::websocket::stream::set_option.
@par Example
Setting the maximum read message size.
@code
...
websocket::stream<ip::tcp::socket> ws(ios);
ws.set_option(read_message_max{65536});
@endcode
*/
#if BEAST_DOXYGEN
using read_message_max = implementation_defined;
#else
struct read_message_max
{
std::size_t value;
explicit
read_message_max(std::size_t n)
: value(n)
{
}
};
#endif
/** Write buffer size option.
Sets the size of the write buffer used by the implementation to

View File

@@ -263,13 +263,6 @@ public:
ping_cb_ = std::move(o.value);
}
/// Set the maximum incoming message size allowed
void
set_option(read_message_max const& o)
{
rd_msg_max_ = o.value;
}
/// Set the size of the write buffer
void
set_option(write_buffer_size const& o)
@@ -377,6 +370,36 @@ public:
return rd_buf_size_;
}
/** Set the maximum incoming message size option.
Sets the largest permissible incoming message size. Message
frame fields indicating a size that would bring the total
message size over this limit will cause a protocol failure.
The default setting is 16 megabytes. A value of zero indicates
a limit of the maximum value of a `std::uint64_t`.
@par Example
Setting the maximum read message size.
@code
ws.read_message_max(65536);
@endcode
@param n The limit on the size of incoming messages.
*/
void
read_message_max(std::size_t n)
{
rd_msg_max_ = n;
}
/// Returns the maximum incoming message size setting.
std::size_t
read_message_max() const
{
return rd_msg_max_;
}
/** Returns the close reason received from the peer.
This is only valid after a read completes with error::closed.

View File

@@ -557,7 +557,7 @@ public:
ws.set_option(write_buffer_size{2048});
ws.binary(false);
ws.read_buffer_size(8192);
ws.set_option(read_message_max{1 * 1024 * 1024});
ws.read_message_max(1 * 1024 * 1024);
try
{
ws.set_option(write_buffer_size{7});
@@ -1815,10 +1815,10 @@ public:
restart(error::closed);
// message size exceeds max
ws.set_option(read_message_max{1});
ws.read_message_max(1);
c.write(ws, cbuf(0x00, 0x00));
restart(error::failed);
ws.set_option(read_message_max{16*1024*1024});
ws.read_message_max(16*1024*1024);
}
}
catch(system_error const&)