Use static_string from Boost.StaticString

This commit is contained in:
Glen Fernandes
2022-04-17 12:30:52 -04:00
parent 17141a331a
commit 24275ac0c6
19 changed files with 80 additions and 1764 deletions
@@ -120,7 +120,7 @@ build_response(
if(it == req.end())
return err(error::no_sec_key);
key = it->value();
if(key.size() > detail::sec_ws_key_type::max_size_n)
if(key.size() > detail::sec_ws_key_type::static_capacity)
return err(error::bad_sec_key);
}
{
@@ -149,7 +149,7 @@ build_response(
{
detail::sec_ws_accept_type acc;
detail::make_sec_ws_accept(acc, key);
res.set(http::field::sec_websocket_accept, acc);
res.set(http::field::sec_websocket_accept, to_string_view(acc));
}
this->build_response_pmd(res, req);
decorate(res);
+6 -6
View File
@@ -248,7 +248,7 @@ public:
goto loop;
if(impl.ctrl_cb)
impl.ctrl_cb(
frame_type::ping, payload);
frame_type::ping, to_string_view(payload));
impl.rd_fb.clear();
impl.template write_ping<
flat_static_buffer_base>(impl.rd_fb,
@@ -336,7 +336,7 @@ public:
impl.rd_buf.consume(len);
// Ignore pong when closing
if(! impl.wr_close && impl.ctrl_cb)
impl.ctrl_cb(frame_type::pong, payload);
impl.ctrl_cb(frame_type::pong, to_string_view(payload));
goto loop;
}
@@ -376,7 +376,7 @@ public:
impl.rd_buf.consume(len);
if(impl.ctrl_cb)
impl.ctrl_cb(frame_type::close,
impl.cr.reason);
to_string_view(impl.cr.reason));
// See if we are already closing
if(impl.status_ == status::closing)
{
@@ -1103,7 +1103,7 @@ loop:
goto loop;
}
if(impl.ctrl_cb)
impl.ctrl_cb(frame_type::ping, payload);
impl.ctrl_cb(frame_type::ping, to_string_view(payload));
detail::frame_buffer fb;
impl.template write_ping<flat_static_buffer_base>(fb,
detail::opcode::pong, payload);
@@ -1119,7 +1119,7 @@ loop:
detail::read_ping(payload, b);
impl.rd_buf.consume(len);
if(impl.ctrl_cb)
impl.ctrl_cb(frame_type::pong, payload);
impl.ctrl_cb(frame_type::pong, to_string_view(payload));
goto loop;
}
// Handle close frame
@@ -1139,7 +1139,7 @@ loop:
impl.cr = cr;
impl.rd_buf.consume(len);
if(impl.ctrl_cb)
impl.ctrl_cb(frame_type::close, impl.cr.reason);
impl.ctrl_cb(frame_type::close, to_string_view(impl.cr.reason));
BOOST_ASSERT(! impl.wr_close);
// _Start the WebSocket Closing Handshake_
do_fail(
@@ -631,7 +631,7 @@ build_request(
req.set(http::field::upgrade, "websocket");
req.set(http::field::connection, "upgrade");
detail::make_sec_ws_key(key);
req.set(http::field::sec_websocket_key, key);
req.set(http::field::sec_websocket_key, to_string_view(key));
req.set(http::field::sec_websocket_version, "13");
this->build_request_pmd(req);
decorator_opt(req);
@@ -677,8 +677,8 @@ on_response(
if(it == res.end())
return err(error::no_sec_accept);
detail::sec_ws_accept_type acc;
detail::make_sec_ws_accept(acc, key);
if(acc.compare(it->value()) != 0)
detail::make_sec_ws_accept(acc, to_string_view(key));
if (to_string_view(acc).compare(it->value()) != 0)
return err(error::bad_sec_accept);
}