diff options
Diffstat (limited to 'lib/LuaTask.cc')
-rw-r--r-- | lib/LuaTask.cc | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/lib/LuaTask.cc b/lib/LuaTask.cc index e38c136..622cb16 100644 --- a/lib/LuaTask.cc +++ b/lib/LuaTask.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: LuaTask.cc,v 1.13 2007-06-14 17:33:50 pixel Exp $ */ +/* $Id: LuaTask.cc,v 1.14 2007-06-17 15:24:44 pixel Exp $ */ #include <LuaTask.h> #include <LuaHandle.h> @@ -126,11 +126,39 @@ int LuaTask::Do() throw (GeneralException) { } else if (task == "HttpClient") { String url = L->tostring(2); t_headers headers; + Variables vars; + + if (L->gettop() >= 4) { + if (!L->istable(4)) { + L->error("Incorrect parameters to HttpClient."); + return TASK_DONE; + } + // read variables + L->push(); + while (L->next(4) != 0) { + String v = L->tostring(-2) + "=" + L->tostring(-1); + vars.Add(v); + L->pop(); + } + } + if (L->gettop() >= 3) { + if (!L->istable(3)) { + L->error("Incorrect parameters to HttpClient."); + return TASK_DONE; + } + // read headers + L->push(); + while (L->next(3) != 0) { + String h = L->tostring(-2) + ": " + L->tostring(-1); + headers.push_back(h); + L->pop(); + } + } b = new Buffer(true); - headers.push_back("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1) Gecko/20061010 Firefox/2.0"); - c = new HttpClient(url, b, "", headers); + //headers.push_back("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1) Gecko/20061010 Firefox/2.0"); + c = new HttpClient(url, b, "", headers, vars); WaitFor(c); Suspend(TASK_ON_HOLD); #endif |