merge from hugo, add parsing requests and wip cgi

This commit is contained in:
hugogogo
2022-08-01 20:41:07 +02:00
parent 16af16084b
commit f252887d53
28 changed files with 971 additions and 71 deletions

View File

@@ -86,12 +86,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];
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;
@@ -144,15 +154,16 @@ 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());
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();
}
}