mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibCore: InspectorServerConnection send responses with multiple writes
This commit is contained in:
parent
dfefd1ec88
commit
720e0a096f
Notes:
sideshowbarker
2024-07-17 08:54:30 +09:00
Author: https://github.com/frhun Commit: https://github.com/SerenityOS/serenity/commit/720e0a096f Pull-request: https://github.com/SerenityOS/serenity/pull/14471 Reviewed-by: https://github.com/alimpfard
@ -209,10 +209,15 @@ public:
|
||||
void send_response(JsonObject const& response)
|
||||
{
|
||||
auto serialized = response.to_string();
|
||||
u32 length = serialized.length();
|
||||
auto bytes_to_send = serialized.bytes();
|
||||
u32 length = bytes_to_send.size();
|
||||
// FIXME: Propagate errors
|
||||
MUST(m_socket->write({ (u8 const*)&length, sizeof(length) }));
|
||||
MUST(m_socket->write(serialized.bytes()));
|
||||
auto sent = MUST(m_socket->write({ (u8 const*)&length, sizeof(length) }));
|
||||
VERIFY(sent == sizeof(length));
|
||||
while (!bytes_to_send.is_empty()) {
|
||||
size_t bytes_sent = MUST(m_socket->write(bytes_to_send));
|
||||
bytes_to_send = bytes_to_send.slice(bytes_sent);
|
||||
}
|
||||
}
|
||||
|
||||
void handle_request(JsonObject const& request)
|
||||
|
Loading…
Reference in New Issue
Block a user