summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/CopyJob.h2
-rw-r--r--lib/CopyJob.cc3
-rw-r--r--lib/HttpServ.cc20
-rw-r--r--src/Main.cc21
4 files changed, 31 insertions, 15 deletions
diff --git a/include/CopyJob.h b/include/CopyJob.h
index 2a886c5..3afb098 100644
--- a/include/CopyJob.h
+++ b/include/CopyJob.h
@@ -18,7 +18,7 @@ class CopyJob : public Task {
Handle * s, * d;
bool ds, dd;
ssize_t siz, cursiz;
- char buffer[COPY_BUFSIZ];
+ char buffer[COPY_BUFSIZ + 1];
int r;
};
diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc
index 1e151c3..877b113 100644
--- a/lib/CopyJob.cc
+++ b/lib/CopyJob.cc
@@ -26,6 +26,9 @@ int CopyJob::Do() throw (GeneralException) {
tr = siz >= 0 ? siz - cursiz : COPY_BUFSIZ;
try {
r = s->read(buffer, MIN(COPY_BUFSIZ, tr));
+ cerr << "CopyJob: read " << r << " bytes: " << endl;
+ buffer[r] = 0;
+ cerr << buffer << endl;
}
catch (IOAgain e) {
WaitFor(s, W4_READING);
diff --git a/lib/HttpServ.cc b/lib/HttpServ.cc
index d2c3c02..1e37f94 100644
--- a/lib/HttpServ.cc
+++ b/lib/HttpServ.cc
@@ -60,7 +60,7 @@ int ProcessRequest::Do() {
bad = false;
-// cerr << "---- Got a request from handle " << s.GetHandle() << " \n";
+ cerr << "---- Got a request from handle " << s.GetHandle() << " \n";
post = ParseUri(file, domain, &b);
@@ -70,7 +70,7 @@ int ProcessRequest::Do() {
do {
int p;
b >> t;
-// cerr << "Read Request (n): " << t << endl;
+ cerr << "Read Request (n): " << t << endl;
if ((t.strstr("Content-Length: ") == 0) || (t.strstr("Content-length: ") == 0)) {
// cerr << "Saw 'Content-Lenght:', reading length from '" << t.extract(16) << "'\n";
len = t.extract(16).to_int();
@@ -87,7 +87,7 @@ int ProcessRequest::Do() {
}
} while (t.strlen());
-// cerr << "---- Processing it.\n";
+ cerr << "---- Processing it.\n";
hasvars = false;
@@ -122,7 +122,7 @@ int ProcessRequest::Do() {
ParseVars(&b, len);
}
-// cerr << " Domain = '" << domain << "' - File = '" << file << "'\n";
+ cerr << " Domain = '" << domain << "' - File = '" << file << "'\n";
if (!bad) {
// Nous vérifions le domaine.
@@ -167,11 +167,11 @@ int ProcessRequest::Do() {
SendHeads(&b, GetMime(file), String("Accept-Ranges: bytes") + endhl + "Content-Length: " + (unsigned long long int) i->GetSize() + endhl, i->GetModif());
i->SetNonBlock();
a = new CopyJob(i, &s);
-// cerr << "File found, dumping.\n";
+ cerr << "File found, dumping.\n";
}
catch (IOGeneral e) {
ShowError(&b);
-// cerr << "File not found, error showed.\n";
+ cerr << "File not found, error showed.\n";
}
}
}
@@ -180,7 +180,7 @@ int ProcessRequest::Do() {
delete Vars;
delete Heads;
-// cerr << "---- Sending header buffer.\n";
+ cerr << "---- Sending header buffer.\n";
c = new CopyJob(&b, &s, -1, false);
WaitFor(c);
current = 3;
@@ -190,7 +190,7 @@ int ProcessRequest::Do() {
delete c;
if (a) {
-// cerr << "---- Sending contents.\n";
+ cerr << "---- Sending contents.\n";
a->Restart();
WaitFor(a);
current = 4;
@@ -199,7 +199,7 @@ int ProcessRequest::Do() {
case 4:
if (a) delete a;
-// cerr << "---- End of Request.\n";
+ cerr << "---- End of Request.\n";
}
return TASK_DONE;
}
@@ -271,7 +271,7 @@ bool ProcessRequest::ParseUri(String & file, String & domain, Handle * s) {
ssize_t sppos;
*s >> t;
-// cerr << "Read Request (1): " << t << endl;
+ cerr << "Read Request (1): " << t << endl;
bad = false;
diff --git a/src/Main.cc b/src/Main.cc
index 2bd0b0a..4663a02 100644
--- a/src/Main.cc
+++ b/src/Main.cc
@@ -1,5 +1,5 @@
#include <unistd.h>
-#include <list>
+#include <list.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "Handle.h"
@@ -17,6 +17,7 @@
#include "InPipe.h"
#include "Image.h"
#include "CopyJob.h"
+#include "IRC.h"
InPipe * in;
@@ -88,11 +89,20 @@ Action * java = new Message("Applet JAVA",
</center>
", "java");
-Action * Liste[] = {a1, a2, a3, a4, a5, ad, java};
-String Labels[] = {"Action 1", "Action 2", "Action 3", "Action 4", "Action 5", "Action dynamique", "Essai de java"};
+Action * up = new Message("Test d'upload",
+"
+<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"/bin/start\" METHOD=POST>
+<INPUT TYPE=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1000\">
+Send this file: <INPUT NAME=\"userfile\" TYPE=\"file\">
+<INPUT TYPE=\"submit\" VALUE=\"Send File\">
+</FORM>
+", "upload");
+
+Action * Liste[] = {a1, a2, a3, a4, a5, ad, java, up};
+String Labels[] = {"Action 1", "Action 2", "Action 3", "Action 4", "Action 5", "Action dynamique", "Essai de java", "Test d'upload"};
Action * buildmenu(void) {
- return new Menu("Menu Principal", "start", Labels, Liste, 7);
+ return new Menu("Menu Principal", "start", Labels, Liste, 8);
}
int main(int argc, char ** argv) {
@@ -128,6 +138,9 @@ int main(int argc, char ** argv) {
try {
HttpServ h(buildmenu(), port.to_int());
+ IRC i("botalacon");
+// i.Connect();
+// i.MainLoop();
TaskMan::MainLoop();
}
catch (GeneralException e) {