forked from boostorg/beast
@@ -304,6 +304,22 @@ text() const
|
||||
return impl_->wr_opcode == detail::opcode::text;
|
||||
}
|
||||
|
||||
template<class NextLayer, bool deflateSupported>
|
||||
void
|
||||
stream<NextLayer, deflateSupported>::
|
||||
compress(bool value)
|
||||
{
|
||||
impl_->wr_compress_opt = value;
|
||||
}
|
||||
|
||||
template<class NextLayer, bool deflateSupported>
|
||||
bool
|
||||
stream<NextLayer, deflateSupported>::
|
||||
compress() const
|
||||
{
|
||||
return impl_->wr_compress_opt;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// _Fail the WebSocket Connection_
|
||||
|
||||
@@ -221,11 +221,13 @@ struct stream<NextLayer, deflateSupported>::impl_type
|
||||
// Called just before sending
|
||||
// the first frame of each message
|
||||
void
|
||||
begin_msg()
|
||||
begin_msg(std::size_t n_bytes)
|
||||
{
|
||||
wr_frag = wr_frag_opt;
|
||||
wr_compress =
|
||||
this->pmd_enabled() && wr_compress_opt;
|
||||
this->pmd_enabled() &&
|
||||
wr_compress_opt &&
|
||||
this->should_compress(n_bytes);
|
||||
|
||||
// Maintain the write buffer
|
||||
if( this->pmd_enabled() ||
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
// Set up the outgoing frame header
|
||||
if(! impl.wr_cont)
|
||||
{
|
||||
impl.begin_msg();
|
||||
impl.begin_msg(beast::buffer_bytes(bs));
|
||||
fh_.rsv1 = impl.wr_compress;
|
||||
}
|
||||
else
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(impl.wr_buf_size != 0);
|
||||
remain_ = buffer_bytes(cb_);
|
||||
remain_ = beast::buffer_bytes(cb_);
|
||||
if(remain_ > impl.wr_buf_size)
|
||||
how_ = do_nomask_frag;
|
||||
else
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(impl.wr_buf_size != 0);
|
||||
remain_ = buffer_bytes(cb_);
|
||||
remain_ = beast::buffer_bytes(cb_);
|
||||
if(remain_ > impl.wr_buf_size)
|
||||
how_ = do_mask_frag;
|
||||
else
|
||||
@@ -207,7 +207,7 @@ operator()(
|
||||
{
|
||||
// send a single frame
|
||||
fh_.fin = fin_;
|
||||
fh_.len = buffer_bytes(cb_);
|
||||
fh_.len = beast::buffer_bytes(cb_);
|
||||
impl.wr_fb.clear();
|
||||
detail::write<flat_static_buffer_base>(
|
||||
impl.wr_fb, fh_);
|
||||
@@ -462,13 +462,13 @@ operator()(
|
||||
more_ = impl.deflate(b, cb_, fin_, in_, ec);
|
||||
if(impl.check_stop_now(ec))
|
||||
goto upcall;
|
||||
n = buffer_bytes(b);
|
||||
n = beast::buffer_bytes(b);
|
||||
if(n == 0)
|
||||
{
|
||||
// The input was consumed, but there is
|
||||
// no output due to compression latency.
|
||||
BOOST_ASSERT(! fin_);
|
||||
BOOST_ASSERT(buffer_bytes(cb_) == 0);
|
||||
BOOST_ASSERT(beast::buffer_bytes(cb_) == 0);
|
||||
goto upcall;
|
||||
}
|
||||
if(fh_.mask)
|
||||
@@ -622,7 +622,7 @@ write_some(bool fin,
|
||||
detail::frame_header fh;
|
||||
if(! impl.wr_cont)
|
||||
{
|
||||
impl.begin_msg();
|
||||
impl.begin_msg(beast::buffer_bytes(buffers));
|
||||
fh.rsv1 = impl.wr_compress;
|
||||
}
|
||||
else
|
||||
@@ -634,7 +634,7 @@ write_some(bool fin,
|
||||
fh.op = impl.wr_cont ?
|
||||
detail::opcode::cont : impl.wr_opcode;
|
||||
fh.mask = impl.role == role_type::client;
|
||||
auto remain = buffer_bytes(buffers);
|
||||
auto remain = beast::buffer_bytes(buffers);
|
||||
if(impl.wr_compress)
|
||||
{
|
||||
|
||||
@@ -648,14 +648,14 @@ write_some(bool fin,
|
||||
b, cb, fin, bytes_transferred, ec);
|
||||
if(impl.check_stop_now(ec))
|
||||
return bytes_transferred;
|
||||
auto const n = buffer_bytes(b);
|
||||
auto const n = beast::buffer_bytes(b);
|
||||
if(n == 0)
|
||||
{
|
||||
// The input was consumed, but there
|
||||
// is no output due to compression
|
||||
// latency.
|
||||
BOOST_ASSERT(! fin);
|
||||
BOOST_ASSERT(buffer_bytes(cb) == 0);
|
||||
BOOST_ASSERT(beast::buffer_bytes(cb) == 0);
|
||||
fh.fin = false;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user