修复访问http目录下索引文件相关的bug

This commit is contained in:
xia-chu 2023-08-08 14:24:01 +08:00
parent 08299b6652
commit 2e05119df1

View File

@ -119,7 +119,7 @@ static string searchIndexFile(const string &dir){
}
set<string> setFile;
while ((pDirent = readdir(pDir)) != NULL) {
static set<const char *, StrCaseCompare> indexSet = {"index.html", "index.htm", "index"};
static set<const char *, StrCaseCompare> indexSet = {"index.html", "index.htm"};
if (indexSet.find(pDirent->d_name) != indexSet.end()) {
string ret = pDirent->d_name;
closedir(pDir);
@ -573,10 +573,13 @@ void HttpFileManager::onAccessPath(Session &sender, Parser &parser, const HttpFi
if (!indexFile.empty()) {
// 发现该文件夹下有index文件
file_path = pathCat(file_path, indexFile);
if (!File::is_dir(file_path.data())) {
// 不是文件夹
parser.setUrl(pathCat(parser.url(), indexFile));
accessFile(sender, parser, media_info, file_path, cb);
return;
}
}
string strMenu;
//生成文件夹菜单索引
if (!makeFolderMenu(parser.url(), file_path, strMenu)) {