summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2017-07-01 19:14:03 +0200
committerJulian Andres Klode <jak@debian.org>2017-07-01 19:14:03 +0200
commitd47fb34ae03566feec7fec6dccba80e45fa03e6f (patch)
tree6b0c87698c823741b3253874663ba92dc7d1b78a
parent9a34c8557ac02e691bc66a5313103569a5e646ac (diff)
downloadapt-d47fb34ae03566feec7fec6dccba80e45fa03e6f.tar.gz
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.
-rw-r--r--methods/basehttp.cc5
1 files changed, 4 insertions, 1 deletions
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<unsigned long long>::max())
return _error->Errno("HeaderLine", _("The HTTP server sent an invalid Content-Length header"));
else if (*DownloadSizePtr == 0)