@@ -7,8 +7,8 @@ WSJCppLightWebHttpHandlerWebFolder::WSJCppLightWebHttpHandlerWebFolder(const std
7
7
: WSJCppLightWebHttpHandlerBase(" web-folder" ) {
8
8
9
9
TAG = " WSJCppLightWebHttpHandlerWebFolder" ;
10
- m_sPrefixPath = sPrefixPath ;
11
- m_sWebFolder = sWebFolder ;
10
+ m_sPrefixPath = WSJCppCore::doNormalizePath ( sPrefixPath + " / " ) ;
11
+ m_sWebFolder = WSJCppCore::doNormalizePath ( sWebFolder + " / " ) ;
12
12
}
13
13
14
14
// ----------------------------------------------------------------------
@@ -38,11 +38,15 @@ bool WSJCppLightWebHttpHandlerWebFolder::canHandle(const std::string &sWorkerId,
38
38
bool WSJCppLightWebHttpHandlerWebFolder::handle (const std::string &sWorkerId , WSJCppLightWebHttpRequest *pRequest) {
39
39
std::string _tag = TAG + " -" + sWorkerId ;
40
40
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" ;
44
46
}
45
- std::string sFilePath = m_sWebFolder + sRequestPath ;
47
+ std::string sFilePath = m_sWebFolder + sRequestPath2 ;
48
+ // WSJCppLog::warn(_tag, sFilePath);
49
+
46
50
if (WSJCppCore::fileExists (sFilePath )) {
47
51
WSJCppLightWebHttpResponse resp (pRequest->getSockFd ());
48
52
resp.cacheSec (60 ).ok ().sendFile (sFilePath );
0 commit comments