1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:57:35 +00:00

LibHTTP: Respect the 'Connection: close' header on keep-alive jobs

If the server responds with this header, we _must_ close the connection,
as the server is allowed to ignore the socket and not respond to
anything past that response.
Fixes some RequestServer spins.
This commit is contained in:
Ali Mohammad Pur 2021-09-30 12:19:54 +03:30 committed by Andreas Kling
parent d16131b100
commit b0a9c5673e
13 changed files with 55 additions and 23 deletions

View file

@ -23,7 +23,7 @@ void NetworkJob::start(NonnullRefPtr<Core::Socket>)
{
}
void NetworkJob::shutdown()
void NetworkJob::shutdown(ShutdownMode)
{
}
@ -40,7 +40,7 @@ void NetworkJob::did_finish(NonnullRefPtr<NetworkResponse>&& response)
dbgln_if(CNETWORKJOB_DEBUG, "{} job did_finish", *this);
VERIFY(on_finish);
on_finish(true);
shutdown();
shutdown(ShutdownMode::DetachFromSocket);
}
void NetworkJob::did_fail(Error error)
@ -56,7 +56,7 @@ void NetworkJob::did_fail(Error error)
dbgln_if(CNETWORKJOB_DEBUG, "{}{{{:p}}} job did_fail! error: {} ({})", class_name(), this, (unsigned)error, to_string(error));
VERIFY(on_finish);
on_finish(false);
shutdown();
shutdown(ShutdownMode::DetachFromSocket);
}
void NetworkJob::did_progress(Optional<u32> total_size, u32 downloaded)