X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/4836d9ebbfbfde987c7f1f907a679c6c1d262ab2..6d3b1b7d7daa7d6383a7c02275d8b410f822e4d2:/lib/network/http_dyn.cpp diff --git a/lib/network/http_dyn.cpp b/lib/network/http_dyn.cpp deleted file mode 100644 index c3a49048..00000000 --- a/lib/network/http_dyn.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include - -DEFINE_REF(eHTTPDyn); -eHTTPDyn::eHTTPDyn(eHTTPConnection *c, std::string result): eHTTPDataSource(c), result(result) -{ - wptr=0; - char buffer[10]; - snprintf(buffer, 10, "%d", size=result.length()); - c->local_header["Content-Length"]=std::string(buffer); - if (c->code == -1) - { - c->code=200; - c->code_descr="OK"; - } -} - -eHTTPDyn::~eHTTPDyn() -{ -} - -int eHTTPDyn::doWrite(int hm) -{ - int tw=size-wptr; - if (tw>hm) - tw=hm; - if (tw<=0) - return -1; - connection->writeBlock(result.c_str()+wptr, tw); - wptr+=tw; - return (size > wptr) ? 1 : -1; -} - -DEFINE_REF(eHTTPDynPathResolver); -DEFINE_REF(eHTTPDynPathResolver::eHTTPDynEntry); - -eHTTPDynPathResolver::eHTTPDynPathResolver() -{ -} - -void eHTTPDynPathResolver::addDyn(std::string request, std::string path, std::string (*function)(std::string, std::string, std::string, eHTTPConnection*)) -{ - dyn.push_back(new eHTTPDynEntry(request, path, function)); -} - -RESULT eHTTPDynPathResolver::getDataSource(eHTTPDataSourcePtr &ptr, std::string request, std::string path, eHTTPConnection *conn) -{ - std::string p, opt; - if (path.find('?')!=std::string::npos) - { - p=path.substr(0, path.find('?')); - opt=path.substr(path.find('?')+1); - } else - { - p=path; - opt=""; - } - for (eSmartPtrList::iterator i(dyn); i != dyn.end(); ++i) - if ((i->path==p) && (i->request==request)) - { - conn->code=-1; - std::string s=i->function(request, path, opt, conn); - - if (!s.empty()) - { - ptr = new eHTTPDyn(conn, s); - return 0; - } - - ptr = new eHTTPError(conn, 500); - return 0; - } - ptr = 0; - return -1; -}