1 #include <lib/network/http_dyn.h>
3 eHTTPDyn::eHTTPDyn(eHTTPConnection *c, std::string result): eHTTPDataSource(c), result(result)
7 snprintf(buffer, 10, "%d", size=result.length());
8 c->local_header["Content-Length"]=std::string(buffer);
20 int eHTTPDyn::doWrite(int hm)
27 connection->writeBlock(result.c_str()+wptr, tw);
29 return (size > wptr) ? 1 : -1;
32 eHTTPDynPathResolver::eHTTPDynPathResolver()
34 #warning autodelete removed
37 void eHTTPDynPathResolver::addDyn(std::string request, std::string path, std::string (*function)(std::string, std::string, std::string, eHTTPConnection*))
39 dyn.push_back(new eHTTPDynEntry(request, path, function));
42 eHTTPDataSource *eHTTPDynPathResolver::getDataSource(std::string request, std::string path, eHTTPConnection *conn)
45 if (path.find('?')!=std::string::npos)
47 p=path.substr(0, path.find('?'));
48 opt=path.substr(path.find('?')+1);
54 for (ePtrList<eHTTPDynEntry>::iterator i(dyn); i != dyn.end(); ++i)
55 if ((i->path==p) && (i->request==request))
58 std::string s=i->function(request, path, opt, conn);
61 return new eHTTPDyn(conn, s);
63 return new eHTTPError(conn, 500);