split respone.cpp file

This commit is contained in:
LuckyLaszlo
2022-08-08 20:36:01 +02:00
parent 7fdc81f5f4
commit a44b9b493a
7 changed files with 311 additions and 308 deletions

View File

@@ -0,0 +1,40 @@
#include "Webserv.hpp"
void Webserv::_delete(Client *client)
{
/*
WIP
https://www.rfc-editor.org/rfc/rfc9110.html#name-delete
*/
std::string path = client->get_path();
path.insert(0, client->assigned_location->root);
/* CGI Here ? */
_delete_file(client, path);
}
void Webserv::_delete_file(Client *client, const std::string &path)
{
if (access(path.c_str(), F_OK) == -1)
{
std::perror("err access()");
client->status = 404;
return ;
}
if (access(path.c_str(), W_OK) == -1)
{
std::perror("err access()");
client->status = 403;
return ;
}
if (remove(path.c_str()) == -1)
{
std::perror("err remove()");
client->status = 500;
return ;
}
}