Files
42_INT_12_webserv/srcs/webserv/method_delete.cpp
LuckyLaszlo 3fe37ea451 DELETE method tested and fixed
+ added 404 for directories without index and autoindex
+ minors adjustements
2022-08-15 18:16:11 +02:00

32 lines
615 B
C++

#include "Webserv.hpp"
void Webserv::_delete(Client *client, const std::string &path)
{
/*
https://www.rfc-editor.org/rfc/rfc9110.html#name-delete
*/
_delete_file(client, path);
}
void Webserv::_delete_file(Client *client, const std::string &path)
{
std::cout << "_delete_file()\n";
client->status = ::eval_file_mode(path, W_OK);
if (client->status)
return;
if (std::remove(path.c_str()) == -1)
{
std::perror("err remove()");
if (errno == ENOTEMPTY || errno == EEXIST)
client->status = 403;
else
client->status = 500;
return ;
}
client->status = 204;
client->response.append(CRLF);
}