summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-06-29 12:23:02 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2020-07-24 16:30:43 +0200
commit9742032dcdc0e72c117ae0c589fbb59452d6d33c (patch)
tree36fd1adcb9baa30a52182c93588340a6a367d45f /methods
parent24d308455a5f8751f57219f211a5672af340099e (diff)
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.
Diffstat (limited to 'methods')
-rw-r--r--methods/http.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/methods/http.cc b/methods/http.cc
index 40a37a8c6..161ecf067 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -846,13 +846,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))
{
@@ -863,6 +856,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");