working on webserver

master
Steffen Pohle 4 hours ago
parent 95abb92cd8
commit d1ed754e60

@ -1,5 +1,6 @@
2026-02-15: 2026-02-15:
- webserver exited if file was not found. Return error code and keep running - webserver exited if file was not found. Return error code and keep running
- webserver did not set the document root as expected
2026-02-06: 2026-02-06:
- fixed: character '=' was ignored in the request - fixed: character '=' was ignored in the request

@ -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;

Loading…
Cancel
Save