wip cgi handling, client contains it's own privates functions to handle request headers and body

This commit is contained in:
hugogogo
2022-08-01 19:30:07 +02:00
parent 031932e887
commit 979a3d20b8
12 changed files with 382 additions and 154 deletions

View File

@@ -79,12 +79,22 @@ void Webserv::_insert_status_line(Client *client)
#define ROOT "website"
#define INDEX "index.html"
#define MAX_FILESIZE 1000000 // (1Mo)
#define MAX_FILESIZE 1000000 // (1Mo)
void Webserv::_get_ressource(Client *client)
{
std::ifstream ifd; // For chunk, ifstream directly in struct CLient for multiples read without close() ?
char buf[MAX_FILESIZE+1];
const char *tmp;
std::ifstream ifd; // For chunk, ifstream directly in struct CLient for multiples read without close() ?
char buf[MAX_FILESIZE+1];
std::string tmp;
// TMP HUGO
//
if (_is_cgi(client))
{
_exec_cgi(client);
return;
}
//
// END TMP HUGO
// Mini parsing à l'arrache du PATH
std::string path;
@@ -128,15 +138,17 @@ void Webserv::_get_ressource(Client *client)
client->response.append("Content-Type: text/html; charset=UTF-8\r\n");
client->response.append("Content-Length: ");
tmp = ::itoa(ifd.gcount()).c_str();
client->response.append(tmp);
tmp = ::itos(ifd.gcount());
client->response.append(tmp.c_str());
client->response.append("\r\n");
// Body
client->response.append("\r\n");
client->response.append(buf);
client->response.append(buf);
ifd.close();
}
}