summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-05-17 20:30:24 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-17 21:28:34 +0200
commit7aca2d181a6580d8064f7eaf134aed27db5a17dd (patch)
tree57d2c2151378157b75e4b89f8957c30add986403 /Userland/Services
parentf1dc8e12d2fa53e82951977429f358405108ed91 (diff)
downloadserenity-7aca2d181a6580d8064f7eaf134aed27db5a17dd.zip
WebServer: Don't read until EOF
There's no guarantee that the client has closed the socket for writing. Instead we should just read until the first empty line. Fixes #7064.
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/WebServer/Client.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp
index 49462bba66..8b30919894 100644
--- a/Userland/Services/WebServer/Client.cpp
+++ b/Userland/Services/WebServer/Client.cpp
@@ -40,15 +40,18 @@ void Client::die()
void Client::start()
{
m_socket->on_ready_to_read = [this] {
- auto raw_request = m_socket->read_all();
- if (raw_request.is_empty()) {
- die();
- return;
+ StringBuilder builder;
+ for (;;) {
+ auto line = m_socket->read_line();
+ if (line.is_empty())
+ break;
+ builder.append(line);
+ builder.append("\r\n");
}
- dbgln("Got raw request: '{}'", String::copy(raw_request));
-
- handle_request(raw_request.bytes());
+ auto request = builder.to_byte_buffer();
+ dbgln("Got raw request: '{}'", String::copy(request));
+ handle_request(request);
die();
};
}