mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-14 16:58:30 +00:00
fix:set_file_content with range request return 416. (#2010)
Co-authored-by: fenlog <bakurise@qq.com>
This commit is contained in:
parent
8794792baa
commit
d647f484a4
2 changed files with 18 additions and 8 deletions
16
httplib.h
16
httplib.h
|
@ -7183,14 +7183,6 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
|
|||
: StatusCode::PartialContent_206;
|
||||
}
|
||||
|
||||
if (detail::range_error(req, res)) {
|
||||
res.body.clear();
|
||||
res.content_length_ = 0;
|
||||
res.content_provider_ = nullptr;
|
||||
res.status = StatusCode::RangeNotSatisfiable_416;
|
||||
return write_response(strm, close_connection, req, res);
|
||||
}
|
||||
|
||||
// Serve file content by using a content provider
|
||||
if (!res.file_content_path_.empty()) {
|
||||
const auto &path = res.file_content_path_;
|
||||
|
@ -7217,6 +7209,14 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
|
|||
});
|
||||
}
|
||||
|
||||
if (detail::range_error(req, res)) {
|
||||
res.body.clear();
|
||||
res.content_length_ = 0;
|
||||
res.content_provider_ = nullptr;
|
||||
res.status = StatusCode::RangeNotSatisfiable_416;
|
||||
return write_response(strm, close_connection, req, res);
|
||||
}
|
||||
|
||||
return write_response_with_content(strm, close_connection, req, res);
|
||||
} else {
|
||||
if (res.status == -1) { res.status = StatusCode::NotFound_404; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue