From e5057005049b11af44cb804118f95370f03ab32c Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 29 Oct 2001 17:12:20 +0000 Subject: Going out, commiting... --- lib/HttpServ.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lib/HttpServ.cc') diff --git a/lib/HttpServ.cc b/lib/HttpServ.cc index b354f69..69dff1e 100644 --- a/lib/HttpServ.cc +++ b/lib/HttpServ.cc @@ -2,6 +2,7 @@ #include "Action.h" #include "HttpServ.h" #include "Buffer.h" +#include "ReadJob.h" #include "config.h" String endhl = "\r\n", endnl = "\n"; @@ -14,14 +15,18 @@ HttpServ::HttpServ(int port, const String & nname) : name(nname), localport(port void HttpServ::MainLoop(Action * p) { while (1) { - ProcessRequest(p, Socket(Listener.Accept())); + ProcessRequest(p, Listener.Accept()); } } void HttpServ::ProcessRequest(Action * p, Socket s) { String file, domain, t; + Buffer b; + ReadJob c(s, b); Action * f; int len; + + c.Do(); bad = false; @@ -29,11 +34,11 @@ void HttpServ::ProcessRequest(Action * p, Socket s) { cerr << "Got a request\n----\n"; - bool post = ParseUri(file, domain, s); + bool post = ParseUri(file, domain, b); len = -1; do { - s >> t; + b >> t; cerr << t << endl; if ((t.strstr("Content-Length: ") == 0) || (t.strstr("Content-length: ") == 0)) { cerr << "Saw 'Content-Lenght:', reading length from '" << t.extract(16) << "'\n"; @@ -109,7 +114,7 @@ void HttpServ::ProcessRequest(Action * p, Socket s) { cerr << "----\n"; } -void HttpServ::ParseVars(Socket & s, int len) { +void HttpServ::ParseVars(Handle & s, int len) { String t, v; char conv[3], l; int hconv, nbvars; @@ -169,7 +174,7 @@ void HttpServ::ParseVars(Socket & s, int len) { * c'est à dire la méthode demandée par le client. */ -bool HttpServ::ParseUri(String & file, String & domain, Socket & s) { +bool HttpServ::ParseUri(String & file, String & domain, Handle & s) { String t, Uri; bool post = false; char * p = NULL; @@ -228,7 +233,7 @@ bool HttpServ::ParseUri(String & file, String & domain, Socket & s) { /* * Ceci sert à rediriger le navigateur vers l'url de démarrage. */ -void HttpServ::SendRedirect(Socket & s) { +void HttpServ::SendRedirect(Handle & s) { s << "HTTP/1.1 301 Moved Permanently" << endhl << "Server: " << name << endhl << "Location: http://127.0.0.1:" << localport << "/bin/start" << endhl << @@ -245,7 +250,7 @@ void HttpServ::SendRedirect(Socket & s) { * Nous envoyons les entetes de réponse HTTP. */ -void HttpServ::SendHeads(Socket & s, const String & mime) { +void HttpServ::SendHeads(Handle & s, const String & mime) { s << "HTTP/1.1 200 OK" << endhl << "Server: " << name << endhl << "Cache-Control: no-cache" << endhl << @@ -257,7 +262,7 @@ void HttpServ::SendHeads(Socket & s, const String & mime) { * Affichage d'une erreur 404. */ -void HttpServ::ShowError(Socket & s) { +void HttpServ::ShowError(Handle & s) { s << "HTTP/1.1 404 Not Found" << endhl << "Server: " << name << endhl << "Cache-Control: no-cache" << endhl << -- cgit v1.2.3