From fe4201380bd377aebd25bd96a06a7eda6c74a533 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 1 Jul 2021 15:38:10 +0200 Subject: 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 --- methods/basehttp.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'methods') 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; -- cgit v1.2.3-70-g09d2