aboutsummaryrefslogtreecommitdiff
path: root/src/deps/libuwsockets.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-16 00:13:51 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-16 00:13:51 -0700
commit2852520d9047bbdb172fc4afa29dfe4d97c2a501 (patch)
tree8f4df7bb91b24b5e218631482d58846598ddc1e6 /src/deps/libuwsockets.cpp
parentabf3a134331161be7be261983601eee507cc965a (diff)
downloadbun-2852520d9047bbdb172fc4afa29dfe4d97c2a501.tar.gz
bun-2852520d9047bbdb172fc4afa29dfe4d97c2a501.tar.zst
bun-2852520d9047bbdb172fc4afa29dfe4d97c2a501.zip
Fix WebSocket server sending invalid data at the end
Diffstat (limited to '')
-rw-r--r--src/deps/libuwsockets.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/deps/libuwsockets.cpp b/src/deps/libuwsockets.cpp
index d542b7ecb..271794019 100644
--- a/src/deps/libuwsockets.cpp
+++ b/src/deps/libuwsockets.cpp
@@ -488,15 +488,17 @@ uws_sendstatus_t uws_ws_send_with_options(int ssl, uws_websocket_t *ws,
if (ssl) {
uWS::WebSocket<true, true, void *> *uws =
(uWS::WebSocket<true, true, void *> *)ws;
- return (uws_sendstatus_t)uws->send(std::string_view(message),
+ return (uws_sendstatus_t)uws->send(std::string_view(message, length),
+ (uWS::OpCode)(unsigned char)opcode,
+ compress, fin);
+ } else {
+
+ uWS::WebSocket<false, true, void *> *uws =
+ (uWS::WebSocket<false, true, void *> *)ws;
+ return (uws_sendstatus_t)uws->send(std::string_view(message, length),
(uWS::OpCode)(unsigned char)opcode,
compress, fin);
}
- uWS::WebSocket<false, true, void *> *uws =
- (uWS::WebSocket<false, true, void *> *)ws;
- return (uws_sendstatus_t)uws->send(std::string_view(message),
- (uWS::OpCode)(unsigned char)opcode,
- compress, fin);
}
uws_sendstatus_t uws_ws_send_fragment(int ssl, uws_websocket_t *ws,
@@ -520,12 +522,12 @@ uws_sendstatus_t uws_ws_send_first_fragment(int ssl, uws_websocket_t *ws,
uWS::WebSocket<true, true, void *> *uws =
(uWS::WebSocket<true, true, void *> *)ws;
return (uws_sendstatus_t)uws->sendFirstFragment(
- std::string_view(message), uWS::OpCode::BINARY, compress);
+ std::string_view(message, length), uWS::OpCode::BINARY, compress);
}
uWS::WebSocket<false, true, void *> *uws =
(uWS::WebSocket<false, true, void *> *)ws;
return (uws_sendstatus_t)uws->sendFirstFragment(
- std::string_view(message), uWS::OpCode::BINARY, compress);
+ std::string_view(message, length), uWS::OpCode::BINARY, compress);
}
uws_sendstatus_t
uws_ws_send_first_fragment_with_opcode(int ssl, uws_websocket_t *ws,