1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:17:45 +00:00

WebContent: Support sending large responses to the WebDriver client

Some endpoints, like /session/{id}/screenshot, will require sending
large data to the client. We won't be able to write all of the data in
one shot, so loop over the data until we've sent it all (or fail).
This commit is contained in:
Timothy Flynn 2022-11-02 12:53:03 -04:00 committed by Linus Groh
parent 63c459b6c1
commit 819598aecf

View file

@ -197,7 +197,12 @@ ErrorOr<void> Client::send_response(StringView content, HTTP::HttpRequest const&
auto builder_contents = builder.to_byte_buffer();
TRY(m_socket->write(builder_contents));
TRY(m_socket->write(content.bytes()));
while (!content.is_empty()) {
auto bytes_sent = TRY(m_socket->write(content.bytes()));
content = content.substring_view(bytes_sent);
}
log_response(200, request);
auto keep_alive = false;