diff options
author | Julian Andres Klode <jak@debian.org> | 2017-07-01 19:14:03 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2017-07-02 04:25:09 +0200 |
commit | 9f85bf8883e3c65a461abff2a0a40d01f8a1c95a (patch) | |
tree | e9f3204126c4a2fbd98627c89e3b31cf2176e883 /methods | |
parent | a65d028ed50156959a16a2547853d9c427332a41 (diff) |
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)
Diffstat (limited to 'methods')
-rw-r--r-- | methods/basehttp.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/methods/basehttp.cc b/methods/basehttp.cc index d7d9bccd0..f79f26a7c 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) |