#include <lib/network/httpd.h>
#include <sys/socket.h>
+#include <lib/base/smartptr.h>
#include <lib/base/estring.h>
#include <error.h>
#include <errno.h>
#include <time.h>
#include <ctype.h>
+#include <lib/network/http_dyn.h>
+#include <lib/network/http_file.h>
+
eHTTPDataSource::eHTTPDataSource(eHTTPConnection *c): connection(c)
{
}
return 0;
}
+DEFINE_REF(eHTTPError);
+
eHTTPError::eHTTPError(eHTTPConnection *c, int errcode): eHTTPDataSource(c), errcode(errcode)
{
std::string error="unknown error";
void eHTTPConnection::destruct()
{
+ eDebug("destruct, this %p!", this);
gotHangup();
delete this;
}
{
if (data && remotestate == stateData)
data->haveData(0, 0);
- if (data)
- {
- delete data;
- data=0;
- }
+ data = 0;
transferDone(0);
localstate=stateWait;
#endif
if (persistent)
{
- if (data)
- delete data;
- data=0;
- localstate=stateWait;
+ data = 0;
+ localstate = stateWait;
} else
close(); // bye, bye, remote
return 1;
del[1]=line.find(" ", del[0]+1);
if (del[0]==-1)
{
- if (data)
- delete data;
+ data = 0;
eDebug("request buggy");
httpversion="HTTP/1.0";
data=new eHTTPError(this, 400);
if (parent)
{
- for (ePtrList<eHTTPPathResolver>::iterator i(parent->resolver); i != parent->resolver.end(); ++i)
- {
- if ((data=i->getDataSource(request, requestpath, this)))
+ for (eSmartPtrList<iHTTPPathResolver>::iterator i(parent->resolver); i != parent->resolver.end(); ++i)
+ if (!(i->getDataSource(data, request, requestpath, this)))
break;
- }
localstate=stateResponse; // can be overridden by dataSource
} else
data=createDataSource(this);
if (!data)
{
- if (data)
- delete data;
- data=new eHTTPError(this, 404);
+ data = 0;
+ data = new eHTTPError(this, 404);
}
if (content_length || // if content-length is set, we have content
void eHTTPConnection::gotError(int err)
{
- if (data)
- {
- delete data;
- data=0;
- }
+ data = 0;
transferDone(err);
delete this;
}
eDebug("[NET] httpd server FAILED on port %d", port);
else
eDebug("[NET] httpd server started on port %d", port);
-#warning resolver autodelete removed
}
eHTTPConnection::~eHTTPConnection()
{
+ eDebug("HTTP connection destruct");
if ((!persistent) && (state()!=Idle))
eWarning("~eHTTPConnection, status still %d", state());
- if (data)
- delete data;
}
void eHTTPD::newConnection(int socket)