|
|
|
@ -257,7 +257,7 @@ int WebServerClient::SendResponseFile (WebRequestBuffer *request, std::string fn
|
|
|
|
filetype = GetFileType(fname);
|
|
|
|
filetype = GetFileType(fname);
|
|
|
|
filefd = open(fullfname.c_str(), O_RDONLY);
|
|
|
|
filefd = open(fullfname.c_str(), O_RDONLY);
|
|
|
|
if (filefd < 0) {
|
|
|
|
if (filefd < 0) {
|
|
|
|
debug ("could not open file '%s' for reading. Error:%s\n",
|
|
|
|
debug ("could not open file '%s' for reading. Error:%s",
|
|
|
|
fullfname.c_str(), strerror(errno));
|
|
|
|
fullfname.c_str(), strerror(errno));
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// set errorcode and reopen error file
|
|
|
|
// set errorcode and reopen error file
|
|
|
|
@ -267,7 +267,7 @@ int WebServerClient::SendResponseFile (WebRequestBuffer *request, std::string fn
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((filefd != 0) && (fstat (filefd, &filestat) != 0)) {
|
|
|
|
if ((filefd != 0) && (fstat (filefd, &filestat) != 0)) {
|
|
|
|
debug ("could not get stats on file '%s'. Error:%s\n",
|
|
|
|
debug ("could not get stats on file '%s'. Error:%s",
|
|
|
|
fullfname.c_str(), strerror(errno));
|
|
|
|
fullfname.c_str(), strerror(errno));
|
|
|
|
error = 500;
|
|
|
|
error = 500;
|
|
|
|
fullfname = Get_WebFile_FullPath("error500.html");
|
|
|
|
fullfname = Get_WebFile_FullPath("error500.html");
|
|
|
|
@ -468,13 +468,14 @@ int WebServer::Loop() {
|
|
|
|
delete tcpclient;
|
|
|
|
delete tcpclient;
|
|
|
|
return -2;
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
webclient->SetDecoumentRoot("./www");
|
|
|
|
webclient->SetDecoumentRoot(conf_docroot);
|
|
|
|
webclients.push_back(webclient);
|
|
|
|
webclients.push_back(webclient);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// go through all the clients and check for new requests
|
|
|
|
// go through all the clients and check for new requests
|
|
|
|
for (wci = webclients.begin(); wci != webclients.end(); wci++) {
|
|
|
|
for (wci = webclients.begin(); wci != webclients.end(); wci++) {
|
|
|
|
|
|
|
|
int again = 0;
|
|
|
|
WebRequestBuffer *reqbuffer = NULL;
|
|
|
|
WebRequestBuffer *reqbuffer = NULL;
|
|
|
|
webclient = *wci;
|
|
|
|
webclient = *wci;
|
|
|
|
|
|
|
|
|
|
|
|
@ -487,7 +488,10 @@ int WebServer::Loop() {
|
|
|
|
if (wci == webclients.end()) continue;
|
|
|
|
if (wci == webclients.end()) continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (reqbuffer->RequestComplete()) {
|
|
|
|
else if (reqbuffer->RequestComplete()) {
|
|
|
|
if (HandleRequest(reqbuffer, *wci) == 1) continue;
|
|
|
|
if (HandleRequest(reqbuffer, *wci) == 1) {
|
|
|
|
|
|
|
|
wci = webclients.begin();
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
// error handling request, remove and delete webclient.
|
|
|
|
// error handling request, remove and delete webclient.
|
|
|
|
webclients.remove(webclient);
|
|
|
|
webclients.remove(webclient);
|
|
|
|
delete webclient;
|
|
|
|
delete webclient;
|
|
|
|
|