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
commit 819598aecf
Notes: sideshowbarker 2024-07-17 22:01:16 +09:00

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;