@@ -7,8 +7,8 @@ WSJCppLightWebHttpHandlerWebFolder::WSJCppLightWebHttpHandlerWebFolder(const std
77: WSJCppLightWebHttpHandlerBase(" web-folder" ) {
88
99 TAG = " WSJCppLightWebHttpHandlerWebFolder" ;
10- m_sPrefixPath = sPrefixPath ;
11- m_sWebFolder = sWebFolder ;
10+ m_sPrefixPath = WSJCppCore::doNormalizePath ( sPrefixPath + " / " ) ;
11+ m_sWebFolder = WSJCppCore::doNormalizePath ( sWebFolder + " / " ) ;
1212}
1313
1414// ----------------------------------------------------------------------
@@ -38,11 +38,15 @@ bool WSJCppLightWebHttpHandlerWebFolder::canHandle(const std::string &sWorkerId,
3838bool WSJCppLightWebHttpHandlerWebFolder::handle (const std::string &sWorkerId , WSJCppLightWebHttpRequest *pRequest) {
3939 std::string _tag = TAG + " -" + sWorkerId ;
4040 std::string sRequestPath = pRequest->getRequestPath ();
41- // WSJCppLog::warn(_tag, pRequest->requestPath());
42- if (sRequestPath == " /" ) {
43- sRequestPath = " /index.html" ;
41+ // WSJCppLog::warn(_tag, sRequestPath);
42+ std::string sRequestPath2 = sRequestPath .substr (m_sPrefixPath.length (), sRequestPath .length () - m_sPrefixPath.length ());
43+ // WSJCppLog::warn(_tag, sRequestPath2);
44+ if (sRequestPath2 == " " ) {
45+ sRequestPath2 = " index.html" ;
4446 }
45- std::string sFilePath = m_sWebFolder + sRequestPath ;
47+ std::string sFilePath = m_sWebFolder + sRequestPath2 ;
48+ // WSJCppLog::warn(_tag, sFilePath);
49+
4650 if (WSJCppCore::fileExists (sFilePath )) {
4751 WSJCppLightWebHttpResponse resp (pRequest->getSockFd ());
4852 resp.cacheSec (60 ).ok ().sendFile (sFilePath );
0 commit comments