summaryrefslogtreecommitdiff
path: root/Userland/Services/WebServer
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2023-03-01 17:24:50 +0100
committerLinus Groh <mail@linusgroh.de>2023-03-13 15:16:20 +0000
commitae51c1821c0d32ba40b866d8e5561f6de3359b17 (patch)
tree6bd2d0964841bf5bd56797ad4a887e8e4e3ac63c /Userland/Services/WebServer
parent26516ee1601b0662bb1753f834a179bf1a20082d (diff)
downloadserenity-ae51c1821c0d32ba40b866d8e5561f6de3359b17.zip
Everywhere: Remove unintentional partial stream reads and writes
Diffstat (limited to 'Userland/Services/WebServer')
-rw-r--r--Userland/Services/WebServer/Client.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp
index 571b09da0b..43b40da3e0 100644
--- a/Userland/Services/WebServer/Client.cpp
+++ b/Userland/Services/WebServer/Client.cpp
@@ -192,8 +192,7 @@ ErrorOr<void> Client::send_response(Stream& response, HTTP::HttpRequest const& r
builder.append("\r\n"sv);
auto builder_contents = TRY(builder.to_byte_buffer());
- // FIXME: This should write the entire span.
- TRY(m_socket->write_some(builder_contents));
+ TRY(m_socket->write_until_depleted(builder_contents));
log_response(200, request);
char buffer[PAGE_SIZE];
@@ -235,8 +234,7 @@ ErrorOr<void> Client::send_redirect(StringView redirect_path, HTTP::HttpRequest
builder.append("\r\n"sv);
auto builder_contents = TRY(builder.to_byte_buffer());
- // FIXME: This should write the entire span.
- TRY(m_socket->write_some(builder_contents));
+ TRY(m_socket->write_until_depleted(builder_contents));
log_response(301, request);
return {};
@@ -365,9 +363,8 @@ ErrorOr<void> Client::send_error_response(unsigned code, HTTP::HttpRequest const
header_builder.append("Content-Type: text/html; charset=UTF-8\r\n"sv);
header_builder.appendff("Content-Length: {}\r\n", content_builder.length());
header_builder.append("\r\n"sv);
- // FIXME: This should write the entire span.
- TRY(m_socket->write_some(TRY(header_builder.to_byte_buffer())));
- TRY(m_socket->write_some(TRY(content_builder.to_byte_buffer())));
+ TRY(m_socket->write_until_depleted(TRY(header_builder.to_byte_buffer())));
+ TRY(m_socket->write_until_depleted(TRY(content_builder.to_byte_buffer())));
log_response(code, request);
return {};