X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Fhttp%2Fhttpthread.cpp;h=ceaad4ff136fe078ec9e0e1a723499d2309626e3;hp=55f82b92116413911eab7ee86a43683f485a06fd;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hpb=9b22dd53fe62e312c1647310b7ec43aa127090af diff --git a/src/http/httpthread.cpp b/src/http/httpthread.cpp index 55f82b9..ceaad4f 100644 --- a/src/http/httpthread.cpp +++ b/src/http/httpthread.cpp @@ -1,21 +1,11 @@ #include "../../include/http/httpthread.h" +#include "../../include/http/fmshttprequesthandlerfactory.h" #include "../../include/option.h" #include "../../include/stringfunctions.h" -#include "../../include/http/pages/homepage.h" -#include "../../include/http/pages/optionspage.h" -#include "../../include/http/pages/showcaptchapage.h" -#include "../../include/http/pages/createidentitypage.h" -#include "../../include/http/pages/localidentitiespage.h" -#include "../../include/http/pages/announceidentitypage.h" -#include "../../include/http/pages/addpeerpage.h" -#include "../../include/http/pages/peertrustpage.h" -#include "../../include/http/pages/controlboardpage.h" -#include "../../include/http/pages/peerdetailspage.h" -#include "../../include/http/pages/peermaintenancepage.h" -#include "../../include/http/pages/execquerypage.h" -#include "../../include/http/pages/boardspage.h" -#include "../../include/http/pages/insertedfilespage.h" -#include "../../include/http/pages/confirmpage.h" + +#include +#include +#include #include @@ -25,34 +15,13 @@ HTTPThread::HTTPThread() { - std::string templatestr; - int port; + m_listenport=8080; std::string portstr; Option::Instance()->Get("HTTPListenPort",portstr); - StringFunctions::Convert(portstr,port); - - std::string aclstr; - Option::Instance()->Get("HTTPAccessControl",aclstr); - - // set template - templatestr="Home

Could not find template.htm! Place in program directory and restart!


[CONTENT]"; - FILE *infile=fopen("template.htm","r+b"); - if(infile) - { - fseek(infile,0,SEEK_END); - long len=ftell(infile); - std::vector data(len,0); - fseek(infile,0,SEEK_SET); - fread(&data[0],1,len,infile); - fclose(infile); - templatestr.assign(data.begin(),data.end()); - } - else - { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"HTTPThread::HTTPThread could not open template.htm"); - } + StringFunctions::Convert(portstr,m_listenport); // push back page handlers + /* m_pagehandlers.push_back(new ShowCaptchaPage()); m_pagehandlers.push_back(new OptionsPage(templatestr)); m_pagehandlers.push_back(new LocalIdentitiesPage(templatestr)); @@ -69,27 +38,11 @@ HTTPThread::HTTPThread() m_pagehandlers.push_back(new ConfirmPage(templatestr)); // homepage must be last - catch all page handler m_pagehandlers.push_back(new HomePage(templatestr)); - - m_ctx=0; - m_ctx=shttpd_init(); - shttpd_set_option(m_ctx,"ports",portstr.c_str()); - shttpd_set_option(m_ctx,"acl",aclstr.c_str()); - - shttpd_register_uri(m_ctx,"*",HTTPThread::PageCallback,this); - -} - -HTTPThread::~HTTPThread() -{ - shttpd_fini(m_ctx); - - for(std::vector::iterator i=m_pagehandlers.begin(); i!=m_pagehandlers.end(); i++) - { - delete (*i); - } - + */ + } +/* void HTTPThread::PageCallback(shttpd_arg *arg) { @@ -108,16 +61,26 @@ void HTTPThread::PageCallback(shttpd_arg *arg) } } - -void HTTPThread::Run() +*/ +void HTTPThread::run() { - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"HTTPThread::run thread started."); + m_log->debug("HTTPThread::run thread started."); + + Poco::Net::ServerSocket sock(m_listenport); + Poco::Net::HTTPServerParams* pParams = new Poco::Net::HTTPServerParams; + pParams->setMaxQueued(10); + pParams->setMaxThreads(5); + Poco::Net::HTTPServer srv(new FMSHTTPRequestHandlerFactory,sock,pParams); + + srv.start(); do { - shttpd_poll(m_ctx,1000); + Poco::Thread::sleep(1000); }while(!IsCancelled()); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"HTTPThread::run thread exiting."); + srv.stop(); + + m_log->debug("HTTPThread::run thread exiting."); }