mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:57:34 +00:00
LibCore: InspectorServerConnection send responses with multiple writes
This commit is contained in:
parent
dfefd1ec88
commit
720e0a096f
1 changed files with 8 additions and 3 deletions
|
@ -209,10 +209,15 @@ public:
|
||||||
void send_response(JsonObject const& response)
|
void send_response(JsonObject const& response)
|
||||||
{
|
{
|
||||||
auto serialized = response.to_string();
|
auto serialized = response.to_string();
|
||||||
u32 length = serialized.length();
|
auto bytes_to_send = serialized.bytes();
|
||||||
|
u32 length = bytes_to_send.size();
|
||||||
// FIXME: Propagate errors
|
// FIXME: Propagate errors
|
||||||
MUST(m_socket->write({ (u8 const*)&length, sizeof(length) }));
|
auto sent = MUST(m_socket->write({ (u8 const*)&length, sizeof(length) }));
|
||||||
MUST(m_socket->write(serialized.bytes()));
|
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)
|
void handle_request(JsonObject const& request)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue