Skip to content
Snippets Groups Projects
Unverified Commit 6c0a32c9 authored by Julian Andres Klode's avatar Julian Andres Klode Committed by Andrej Shadura
Browse files

http: Finish copying data from server to file before sending stuff to server

This avoids a case where we read data, then write to the server
and only then realize the connection was closed. It is somewhat
slower, though.
parent 2196eaa3
No related branches found
No related tags found
7 merge requests!35Merge changes from apertis/v2020-updates into apertis/v2020,!34Merge changes from apertis/v2020-security into apertis/v2020,!30Merge buster security from Apertis/v2022dev1,!27Merge changes from apertis/v2019-updates into apertis/v2019,!26Sync apertis updates,!15v2020: Backport HTTP corruption fixes,!11T7140: (Hopefully) Fix HTTP data corruption
......@@ -841,13 +841,6 @@ ResultState HttpServerState::Go(bool ToFile, RequestState &Req)
return Die(Req);
}
if (ServerFd->Fd() != -1 && FD_ISSET(ServerFd->Fd(), &wfds))
{
errno = 0;
if (Out.Write(ServerFd) == false)
return Die(Req);
}
// Send data to the file
if (FileFD->Fd() != -1 && FD_ISSET(FileFD->Fd(), &wfds))
{
......@@ -858,6 +851,13 @@ ResultState HttpServerState::Go(bool ToFile, RequestState &Req)
}
}
if (ServerFd->Fd() != -1 && FD_ISSET(ServerFd->Fd(), &wfds))
{
errno = 0;
if (Out.Write(ServerFd) == false)
return Die(Req);
}
if (Req.MaximumSize > 0 && Req.File.IsOpen() && Req.File.Failed() == false && Req.File.Tell() > Req.MaximumSize)
{
Owner->SetFailReason("MaximumSizeExceeded");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment