apply Range only to a 206 response in write_content_with_provider

This commit is contained in:
Sayed Kaif committed 2026-07-28 13:19:35 +05:30
1 parent 34b7c846d4
commit 23fef15e07
2 files changed
+49 -1

No files matched your search

+10 -1
View File
@@ -11777,7 +11777,16 @@ Server::write_content_with_provider(Stream &strm, const Request &req,
};
if (res.content_length_ > 0) {
if (req.ranges.empty()) {
// Only a 206 response is served as a partial representation. That is the
// condition `apply_ranges()` used when it decided the Content-Length and
// the multipart boundary, and `detail::range_error()` only validates
// `req.ranges` against the content length for a 2xx status. Honouring the
// ranges here under any other status would write a body that disagrees
// with the header we already sent, from an offset nothing has checked.
auto partial =
!req.ranges.empty() && res.status == StatusCode::PartialContent_206;
if (!partial) {
return detail::write_content(strm, res.content_provider_, 0,
res.content_length_, is_shutting_down);
} else if (req.ranges.size() == 1) {