From d1ed754e609111ca76204a3bf3fd0abb3e3042af Mon Sep 17 00:00:00 2001 From: Steffen Pohle Date: Sun, 15 Feb 2026 19:27:49 +0100 Subject: [PATCH] working on webserver --- Changelog | 1 + webserver.cc | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index 5ee1e6d..810a3c1 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ 2026-02-15: - 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: - fixed: character '=' was ignored in the request diff --git a/webserver.cc b/webserver.cc index 61a0b28..342eff5 100644 --- a/webserver.cc +++ b/webserver.cc @@ -257,7 +257,7 @@ int WebServerClient::SendResponseFile (WebRequestBuffer *request, std::string fn filetype = GetFileType(fname); filefd = open(fullfname.c_str(), O_RDONLY); 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)); // // 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)) { - 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)); error = 500; fullfname = Get_WebFile_FullPath("error500.html"); @@ -468,13 +468,14 @@ int WebServer::Loop() { delete tcpclient; return -2; } - webclient->SetDecoumentRoot("./www"); + webclient->SetDecoumentRoot(conf_docroot); webclients.push_back(webclient); } // // go through all the clients and check for new requests for (wci = webclients.begin(); wci != webclients.end(); wci++) { + int again = 0; WebRequestBuffer *reqbuffer = NULL; webclient = *wci; @@ -487,7 +488,10 @@ int WebServer::Loop() { if (wci == webclients.end()) continue; } 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. webclients.remove(webclient); delete webclient;