diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2020-06-29 11:48:28 +0200 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2020-07-24 16:30:43 +0200 |
commit | 24d308455a5f8751f57219f211a5672af340099e (patch) | |
tree | 24149eff2b0527b62194e2f38a0abb861713934f /methods | |
parent | cb743d117bcc666dab4c5948b1227ed2edbd0578 (diff) |
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.
Diffstat (limited to 'methods')
-rw-r--r-- | methods/http.cc | 21 |
1 files changed, 3 insertions, 18 deletions
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 |