新增是否开启浏览http目录的配置选项:#367

This commit is contained in:
xiongziliang 2020-06-30 09:16:02 +08:00
parent bbcb4d41f7
commit 41c75fb66a
4 changed files with 13 additions and 0 deletions

View File

@ -122,6 +122,8 @@ rootPath=./www
sendBufSize=65536 sendBufSize=65536
#https服务器监听端口 #https服务器监听端口
sslport=443 sslport=443
#是否显示文件夹菜单,开启后可以浏览文件夹
dirMenu=1
[multicast] [multicast]
#rtp组播截止组播ip地址 #rtp组播截止组播ip地址

View File

@ -100,11 +100,15 @@ const string kCharSet = HTTP_FIELD"charSet";
const string kRootPath = HTTP_FIELD"rootPath"; const string kRootPath = HTTP_FIELD"rootPath";
//http 404错误提示内容 //http 404错误提示内容
const string kNotFound = HTTP_FIELD"notFound"; const string kNotFound = HTTP_FIELD"notFound";
//是否显示文件夹菜单
const string kDirMenu = HTTP_FIELD"dirMenu";
onceToken token([](){ onceToken token([](){
mINI::Instance()[kSendBufSize] = 64 * 1024; mINI::Instance()[kSendBufSize] = 64 * 1024;
mINI::Instance()[kMaxReqSize] = 4*1024; mINI::Instance()[kMaxReqSize] = 4*1024;
mINI::Instance()[kKeepAliveSecond] = 15; mINI::Instance()[kKeepAliveSecond] = 15;
mINI::Instance()[kDirMenu] = true;
#if defined(_WIN32) #if defined(_WIN32)
mINI::Instance()[kCharSet] = "gb2312"; mINI::Instance()[kCharSet] = "gb2312";
#else #else

View File

@ -193,6 +193,8 @@ extern const string kCharSet;
extern const string kRootPath; extern const string kRootPath;
//http 404错误提示内容 //http 404错误提示内容
extern const string kNotFound; extern const string kNotFound;
//是否显示文件夹菜单
extern const string kDirMenu;
}//namespace Http }//namespace Http
////////////SHELL配置/////////// ////////////SHELL配置///////////

View File

@ -195,6 +195,11 @@ static string searchIndexFile(const string &dir){
} }
static bool makeFolderMenu(const string &httpPath, const string &strFullPath, string &strRet) { static bool makeFolderMenu(const string &httpPath, const string &strFullPath, string &strRet) {
GET_CONFIG(bool, dirMenu, Http::kDirMenu);
if(!dirMenu){
//不允许浏览文件夹
return false;
}
string strPathPrefix(strFullPath); string strPathPrefix(strFullPath);
string last_dir_name; string last_dir_name;
if(strPathPrefix.back() == '/'){ if(strPathPrefix.back() == '/'){