Fix Response::content_length_ not reflecting body size in Logger (Fix #2488)

Server::apply_ranges computed the correct Content-Length header for
body-based responses but never updated content_length_, so the
Logger callback always saw 0. Set content_length_ to the final body
size (post-range/post-compression) alongside the header.
This commit is contained in:
yhirose committed 2026-07-11 15:52:54 -04:00
1 parent 873d701972
commit 06b8b91589
2 files changed
+20 -2

No files matched your search

+2 -2
View File
@@ -12323,8 +12323,8 @@ inline void Server::apply_ranges(const Request &req, Response &res,
}
}
auto length = std::to_string(res.body.size());
res.set_header("Content-Length", length);
res.content_length_ = res.body.size();
res.set_header("Content-Length", std::to_string(res.content_length_));
}
}