diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2021-07-01 15:38:10 +0200 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2021-07-01 15:47:48 +0200 |
commit | fe4201380bd377aebd25bd96a06a7eda6c74a533 (patch) | |
tree | cf53b234c3dd3add97e028035e4b363c6017461a /methods | |
parent | f9e2e914996ce8f0af33d5bfed52e814e0f4a861 (diff) |
Set haveContent to FALSE on `Content-Length: 0`
Set haveContent to HaveContent::FALSE when Content-Length is 0,
and change remaining code to only set it to TRUE if it has not
been set so far.
Closes: #990281
Diffstat (limited to 'methods')
-rw-r--r-- | methods/basehttp.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/methods/basehttp.cc b/methods/basehttp.cc index 6d0b334e3..5dfde9e91 100644 --- a/methods/basehttp.cc +++ b/methods/basehttp.cc @@ -154,7 +154,10 @@ bool RequestState::HeaderLine(string const &Line) /*{{{*/ { auto ContentLength = strtoull(Val.c_str(), NULL, 10); if (ContentLength == 0) + { + haveContent = HaveContent::FALSE; return true; + } if (Encoding == Closes) Encoding = Stream; haveContent = HaveContent::TRUE; @@ -180,7 +183,8 @@ bool RequestState::HeaderLine(string const &Line) /*{{{*/ if (stringcasecmp(Tag,"Content-Type:") == 0) { - haveContent = HaveContent::TRUE; + if (haveContent == HaveContent::UNKNOWN) + haveContent = HaveContent::TRUE; return true; } @@ -190,7 +194,8 @@ bool RequestState::HeaderLine(string const &Line) /*{{{*/ // for such responses. if ((Result == 416 || Result == 206) && stringcasecmp(Tag,"Content-Range:") == 0) { - haveContent = HaveContent::TRUE; + if (haveContent == HaveContent::UNKNOWN) + haveContent = HaveContent::TRUE; // ยง14.16 says 'byte-range-resp-spec' should be a '*' in case of 416 if (Result == 416 && sscanf(Val.c_str(), "bytes */%llu",&TotalFileSize) == 1) @@ -207,7 +212,8 @@ bool RequestState::HeaderLine(string const &Line) /*{{{*/ if (stringcasecmp(Tag,"Transfer-Encoding:") == 0) { - haveContent = HaveContent::TRUE; + if (haveContent == HaveContent::UNKNOWN) + haveContent = HaveContent::TRUE; if (stringcasecmp(Val,"chunked") == 0) Encoding = Chunked; return true; |