mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +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
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…
Add table
Add a link
Reference in a new issue