From d47fb34ae03566feec7fec6dccba80e45fa03e6f 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. --- methods/basehttp.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'methods') diff --git a/methods/basehttp.cc b/methods/basehttp.cc index 5eb8a8e7e..a2f1a6e55 100644 --- a/methods/basehttp.cc +++ b/methods/basehttp.cc @@ -146,6 +146,9 @@ bool RequestState::HeaderLine(string const &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; @@ -154,7 +157,7 @@ bool RequestState::HeaderLine(string const &Line) /*{{{*/ if (Result == 416 || (Result >= 300 && Result < 400)) 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-70-g09d2