From ddc255a6c0026af70a7ca685c2fed24941e7df9c Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Wed, 6 Jan 2021 22:09:29 +0330 Subject: [PATCH] LibHTTP: Take the final EOF read notification into account Fixes the HTTP part of #3691. --- Libraries/LibHTTP/Job.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Libraries/LibHTTP/Job.cpp b/Libraries/LibHTTP/Job.cpp index c9aa3d7220..aa0672b259 100644 --- a/Libraries/LibHTTP/Job.cpp +++ b/Libraries/LibHTTP/Job.cpp @@ -125,6 +125,17 @@ void Job::on_socket_connected() register_on_ready_to_read([&] { if (is_cancelled()) return; + + if (m_state == State::Finished) { + // This is probably just a EOF notification, which means we should receive nothing + // and then get eof() == true. + [[maybe_unused]] auto payload = receive(64); + // These assertions are only correct if "Connection: close". + ASSERT(payload.is_empty()); + ASSERT(eof()); + return; + } + if (m_state == State::InStatus) { if (!can_read_line()) return;