From 24d308455a5f8751f57219f211a5672af340099e Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 29 Jun 2020 11:48:28 +0200 Subject: http: Die(): Do not flush the buffer, error out instead By changing the buffer implementation to return true if it read or wrote something, even on EOF, we should not have a need to flush the buffer in Die() anymore - we should only be calling Die() if the buffer is empty now. --- methods/http.cc | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index 83f1bde8d..40a37a8c6 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -705,29 +705,14 @@ ResultState HttpServerState::Die(RequestState &Req) // Dump the buffer to the file if (Req.State == RequestState::Data) { - if (Req.File.IsOpen() == false) - return ResultState::SUCCESSFUL; // on GNU/kFreeBSD, apt dies on /dev/null because non-blocking // can't be set if (Req.File.Name() != "/dev/null") SetNonBlock(Req.File.Fd(),false); - if (not In.WriteSpace()) - return ResultState::SUCCESSFUL; - while (In.WriteSpace() == true) - { - if (In.Write(MethodFd::FromFd(Req.File.Fd())) == false) - { - _error->Errno("write", _("Error writing to the file")); - return ResultState::TRANSIENT_ERROR; - } - - // Done - if (In.IsLimit() == true) - return ResultState::SUCCESSFUL; + if (In.WriteSpace()) { + _error->Error(_("Data left in buffer")); + return ResultState::TRANSIENT_ERROR; } - - if (In.IsLimit() == true || Persistent == false) - return ResultState::SUCCESSFUL; } // See if this is because the server finished the data stream -- cgit v1.2.3