diff options
-rw-r--r-- | include/HttpServ.h | 3 | ||||
-rw-r--r-- | lib/HttpServ.cc | 21 | ||||
-rw-r--r-- | lib/LuaHttp.cc | 6 |
3 files changed, 25 insertions, 5 deletions
diff --git a/include/HttpServ.h b/include/HttpServ.h index 8861d04..bf0970e 100644 --- a/include/HttpServ.h +++ b/include/HttpServ.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: HttpServ.h,v 1.25 2007-07-23 14:05:42 pixel Exp $ */ +/* $Id: HttpServ.h,v 1.26 2008-01-28 17:30:46 pixel Exp $ */ #ifndef __HTTPSERV_H__ #define __HTTPSERV_H__ @@ -53,6 +53,7 @@ class HttpResponse : public Base { String location; String domain; String server_name; + String file_name; return_code_t return_code; time_t last_modified; Buffer contents; diff --git a/lib/HttpServ.cc b/lib/HttpServ.cc index e902ae4..275112e 100644 --- a/lib/HttpServ.cc +++ b/lib/HttpServ.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: HttpServ.cc,v 1.60 2008-01-28 17:09:18 pixel Exp $ */ +/* $Id: HttpServ.cc,v 1.61 2008-01-28 17:30:46 pixel Exp $ */ #include <vector> @@ -789,11 +789,12 @@ String HttpServ::GetName() { class BuildHttpResponse : public Task { public: - BuildHttpResponse(HttpResponse * _hr, Handle * _out) : hr(_hr), out(_out) { SetBurst(); } + BuildHttpResponse(HttpResponse * _hr, Handle * _out) : hr(_hr), out(_out), file(0) { SetBurst(); } virtual ~BuildHttpResponse() { } virtual String GetName() { return "BuildHttpResponse"; } virtual int Do() throw (GeneralException) { Buffer * b; + Handle * h; switch (current) { case 0: @@ -801,6 +802,12 @@ class BuildHttpResponse : public Task { b = &hr->contents; current = 2; } else { + if (hr->file_name != "") { + file = new Input(hr->file_name); + if (hr->last_modified < 0) { + hr->last_modified = file->GetModif(); + } + } b = new Buffer(); hr->PrepareResponse(b); current = 1; @@ -812,13 +819,20 @@ class BuildHttpResponse : public Task { case 1: delete t; - t = new CopyJob(&hr->contents, out); + if (file) { + h = file; + } else { + h = &hr->contents; + } + t = new CopyJob(h, out); WaitFor(t); current = 2; Suspend(TASK_ON_HOLD); case 2: delete t; + if (file) + delete file; } return TASK_DONE; @@ -826,6 +840,7 @@ class BuildHttpResponse : public Task { private: HttpResponse * hr; Handle * out; + Input * file; Task * t; }; diff --git a/lib/LuaHttp.cc b/lib/LuaHttp.cc index fde40c3..483ef2a 100644 --- a/lib/LuaHttp.cc +++ b/lib/LuaHttp.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: LuaHttp.cc,v 1.25 2008-01-23 17:41:10 pixel Exp $ */ +/* $Id: LuaHttp.cc,v 1.26 2008-01-28 17:30:46 pixel Exp $ */ #include "Domain.h" #include "LuaHttp.h" @@ -205,6 +205,8 @@ int sLua_HttpResponse::HttpResponse_proceed(Lua * L, int n, HttpResponse * res, L->push(res->location); } else if (i == "domain") { L->push(res->domain); + } else if (i == "file_name") { + L->push(res->file_name); } else if (i == "server_name") { L->push(res->server_name); } else if (i == "return_code") { @@ -231,6 +233,8 @@ int sLua_HttpResponse::HttpResponse_proceed(Lua * L, int n, HttpResponse * res, res->location = L->tostring(3); } else if (i == "domain") { res->domain = L->tostring(3); + } else if (i == "file_name") { + res->file_name = L->tostring(3); } else if (i == "server_name") { res->server_name = L->tostring(3); } else if (i == "return_code") { |