diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/HttpServ.cc | 33 | ||||
-rw-r--r-- | lib/TaskMan.cc | 3 |
2 files changed, 27 insertions, 9 deletions
diff --git a/lib/HttpServ.cc b/lib/HttpServ.cc index d2c3c02..4f225d2 100644 --- a/lib/HttpServ.cc +++ b/lib/HttpServ.cc @@ -18,7 +18,7 @@ class ProcessRequest : public Task { virtual int Do(); private: String GetMime(const String &); - bool ParseUri(String &, String &, Handle *); + bool ParseUri(String &, String &, String &, Handle *); void ParseVars(Handle *, int); void ShowError(Handle *); void SendHeads(Handle *, const String &, const String & = "", time_t = -1); @@ -32,7 +32,7 @@ class ProcessRequest : public Task { Action * p; Socket s; - String name, host; + String name, host, gvars; Variables * Vars, * Heads; bool bad, hasvars, post; }; @@ -62,9 +62,10 @@ int ProcessRequest::Do() { // cerr << "---- Got a request from handle " << s.GetHandle() << " \n"; - post = ParseUri(file, domain, &b); + post = ParseUri(file, domain, gvars, &b); Heads = new Variables(); + Vars = new Variables(); len = -1; do { @@ -97,14 +98,11 @@ int ProcessRequest::Do() { if (len == -1) { // cerr << "Error: method POST but no Content-Length\n"; bad = true; - Vars = new Variables(); } else { // cerr << "Got a POST request. Parsing variables. (len = " << len << ")\n"; // Les variables seront initialisées ici. hasvars = true; } - } else { - Vars = new Variables(); } current = 2; @@ -117,6 +115,11 @@ int ProcessRequest::Do() { } case 2: + if (gvars != "") { + Buffer b2; + b2 << gvars; + ParseVars(&b2, gvars.strlen()); + } if (hasvars) { if (c) delete c; ParseVars(&b, len); @@ -221,7 +224,6 @@ void ProcessRequest::ParseVars(Handle * s, int len) { // Les variables sont sous la forme 'var1=val1&var2=val2&val3=var3'. Donc le nombre d'occurences // du caractère '=' indique le nombre de variables. nbvars = t.strchrcnt('='); - Vars = new Variables(nbvars); for (int i = 0; i < nbvars; i++) { // Les variables sont sous la forme 'var1=val1&var2=val2&val3=var3'. Donc on cherche le caractère @@ -251,8 +253,8 @@ void ProcessRequest::ParseVars(Handle * s, int len) { default: v += t[pos++]; } - Vars->SetTo(i, v); } + Vars->Add(v); pos++; } } @@ -264,7 +266,7 @@ void ProcessRequest::ParseVars(Handle * s, int len) { * c'est à dire la méthode demandée par le client. */ -bool ProcessRequest::ParseUri(String & file, String & domain, Handle * s) { +bool ProcessRequest::ParseUri(String & file, String & domain, String & gvars, Handle * s) { String t, Uri; bool post = false; const char * p = 0; @@ -272,6 +274,19 @@ bool ProcessRequest::ParseUri(String & file, String & domain, Handle * s) { *s >> t; // cerr << "Read Request (1): " << t << endl; + + int IPos = t.strchr('?'); + + gvars = ""; + + if (IPos >= 0) { + char * sdup = t.strdup(0, IPos - 1); + gvars = t.extract(IPos + 1); + t = sdup; + free(sdup); + } + +// cerr << "New request: " << t << ", gvars = " << gvars << endl; bad = false; diff --git a/lib/TaskMan.cc b/lib/TaskMan.cc index 89f27f8..be66df3 100644 --- a/lib/TaskMan.cc +++ b/lib/TaskMan.cc @@ -155,6 +155,8 @@ void TaskMan::MainLoop() throw (GeneralException) { /* First, we will check for any burning task and run 'em */ for (TaskList_t::iterator p = TaskList.begin(); p && (p != TaskList.end()); p++) { Task * t = *p; + +// cerr << "-=- TaskMan: task " << t->GetName() << endl; if (t->GetState() == TASK_BURST) { // cerr << "-=- TaskMan: running burning task " << t->GetName() << endl; @@ -202,6 +204,7 @@ void TaskMan::MainLoop() throw (GeneralException) { } else { p->T->SetBurst(); no_burst = 0; + p->dirthy = true; if (!(p->flags & W4_STICKY)) { w4ha.erase(p); p--; |