mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-14 16:58:30 +00:00
Apply range header base on response status code (#1806)
* Enable ignoring range header to generate customized response * Apply range header base on response status code
This commit is contained in:
parent
2064462c35
commit
560854a961
2 changed files with 26 additions and 3 deletions
|
@ -6521,7 +6521,7 @@ inline bool Server::dispatch_request(Request &req, Response &res,
|
|||
inline void Server::apply_ranges(const Request &req, Response &res,
|
||||
std::string &content_type,
|
||||
std::string &boundary) const {
|
||||
if (req.ranges.size() > 1) {
|
||||
if (req.ranges.size() > 1 && res.status == StatusCode::PartialContent_206) {
|
||||
auto it = res.headers.find("Content-Type");
|
||||
if (it != res.headers.end()) {
|
||||
content_type = it->second;
|
||||
|
@ -6539,7 +6539,7 @@ inline void Server::apply_ranges(const Request &req, Response &res,
|
|||
if (res.body.empty()) {
|
||||
if (res.content_length_ > 0) {
|
||||
size_t length = 0;
|
||||
if (req.ranges.empty()) {
|
||||
if (req.ranges.empty() || res.status != StatusCode::PartialContent_206) {
|
||||
length = res.content_length_;
|
||||
} else if (req.ranges.size() == 1) {
|
||||
auto offset_and_length = detail::get_range_offset_and_length(
|
||||
|
@ -6568,7 +6568,7 @@ inline void Server::apply_ranges(const Request &req, Response &res,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (req.ranges.empty()) {
|
||||
if (req.ranges.empty() || res.status != StatusCode::PartialContent_206) {
|
||||
;
|
||||
} else if (req.ranges.size() == 1) {
|
||||
auto offset_and_length =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue