mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
parent
913314f1b1
commit
12c829f6d3
2 changed files with 37 additions and 0 deletions
|
@ -6540,6 +6540,11 @@ inline bool Server::handle_file_request(const Request &req, Response &res,
|
|||
auto path = entry.base_dir + sub_path;
|
||||
if (path.back() == '/') { path += "index.html"; }
|
||||
|
||||
if (detail::is_dir(path)) {
|
||||
res.set_redirect(sub_path + "/", StatusCode::MovedPermanently_301);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (detail::is_file(path)) {
|
||||
for (const auto &kv : entry.headers) {
|
||||
res.set_header(kv.first, kv.second);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue