wip cgi handling, client contains it's own privates functions to handle request headers and body
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user