mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
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.
This commit is contained in:
parent
f1dc8e12d2
commit
7aca2d181a
Notes:
sideshowbarker
2024-07-18 17:55:34 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/7aca2d181a6 Pull-request: https://github.com/SerenityOS/serenity/pull/7218 Issue: https://github.com/SerenityOS/serenity/issues/7064
1 changed files with 10 additions and 7 deletions
|
@ -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();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue