From dd547ebaffd2aceb42e2908f1d5f0ab386af6cb1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 1 Jul 2017 19:14:03 +0200 Subject: http: A response with Content-Length: 0 has no content APT considered any response with a Content-Length to have a body, even if the value of the header was 0. A 0 length body however, is equal to no body. (cherry picked from commit d47fb34ae03566feec7fec6dccba80e45fa03e6f) --- methods/server.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'methods') diff --git a/methods/server.cc b/methods/server.cc index cac77e24c..5afe42eba 100644 --- a/methods/server.cc +++ b/methods/server.cc @@ -163,6 +163,9 @@ bool ServerState::HeaderLine(string Line) if (stringcasecmp(Tag,"Content-Length:") == 0) { + auto ContentLength = strtoull(Val.c_str(), NULL, 10); + if (ContentLength == 0) + return true; if (Encoding == Closes) Encoding = Stream; HaveContent = true; @@ -171,7 +174,7 @@ bool ServerState::HeaderLine(string Line) if (Result == 416) DownloadSizePtr = &JunkSize; - *DownloadSizePtr = strtoull(Val.c_str(), NULL, 10); + *DownloadSizePtr = ContentLength; if (*DownloadSizePtr >= std::numeric_limits::max()) return _error->Errno("HeaderLine", _("The HTTP server sent an invalid Content-Length header")); else if (*DownloadSizePtr == 0) -- cgit v1.2.3