little delete fix in main.cpp
This commit is contained in:
19
memo.txt
19
memo.txt
@@ -1,7 +1,4 @@
|
||||
----Priorité élevée------------------------
|
||||
- CGI (TODO HUGO)
|
||||
|
||||
- Need to test normal body parsing (Verif avec HUGO)
|
||||
|
||||
- curl --resolve, for testing hostname
|
||||
curl -v --resolve server1:4040:127.0.0.1 --resolve server2:4040:127.0.0.1 server1:4040
|
||||
@@ -12,20 +9,10 @@
|
||||
|
||||
- cgi_cpp_status.cpp with POST dont show error page. Normal or not ?
|
||||
|
||||
For non blocking CGI :
|
||||
// We could maybe,
|
||||
// add FD_RD_FR_CHLD to epoll,
|
||||
// return to the main loop,
|
||||
// read FD_RD_FR_CHLD each time epoll say its ready,
|
||||
// then try waitpid() with WNOHANG after each read.
|
||||
// when waitpid() tell us its finish (or maybe when epoll return EPOLLHUP)
|
||||
// then actually parse the script_output and send it to the client.
|
||||
|
||||
- check status in autoindex
|
||||
|
||||
- merge changes from hugo5 to master (attention a pas casse svp :clown:)
|
||||
|
||||
|
||||
----Priorité modérée------------------------
|
||||
- namespace utils ?
|
||||
- change "std::string" to reference "std::string &" in most functions
|
||||
@@ -36,8 +23,8 @@ and add "const" if apropriate.
|
||||
----Priorité faible------------------------
|
||||
- idealy, we should not clear() raw_request after a response,
|
||||
but just the part we actually parsed for this response.
|
||||
I think the client could send multiples request on the same connection one after the other without waiting for response.
|
||||
So raw_request could contain more than the first request we handle.
|
||||
I think in HTTP/1 the client could not send multiples request on the same connection one after the other without waiting for response.
|
||||
So only for HTTP/2 adn HTTP/3 raw_request could contain more than the first request we handle.
|
||||
- chunked request (need testing)
|
||||
- client_body_limit 0 valeur special pour desactiver dans config
|
||||
- gerer le champ "Accept" du client
|
||||
@@ -47,8 +34,6 @@ and add "const" if apropriate.
|
||||
little global timeout on epoll, like 100ms, then find client that actualy need to timeout
|
||||
if (actual_time - client.last_action_time > 10000ms){timeout(client)}
|
||||
- add headers "Date" and "Last-Modified" to response
|
||||
- change "std::string" to reference "std::string &" in most functions
|
||||
and add "const" if apropriate.
|
||||
- Il faut vérifier le path de la requête, voir si le serveur est bien censé délivrer cette ressource et si le client y a accès, avant d'appeler le CGI.
|
||||
|
||||
Valgrind error RESOLVED ! :
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
std::vector<ServerConfig>* servers_config = NULL;
|
||||
try
|
||||
{
|
||||
std::string config = (ac == 2 ? av[1] : "./default.config");
|
||||
|
||||
|
||||
ConfigParser configParser(config);
|
||||
// configParser.print_content();
|
||||
|
||||
// i don't love that servers has to be a pointer...
|
||||
std::vector<ServerConfig>* servers = configParser.parse();
|
||||
// i don't love that servers_config has to be a pointer...
|
||||
servers_config = configParser.parse();
|
||||
|
||||
// use an iterator you moron
|
||||
for (std::vector<ServerConfig>::iterator it = servers->begin(); it < servers->end(); it++)
|
||||
for (std::vector<ServerConfig>::iterator it = servers_config->begin(); it < servers_config->end(); it++)
|
||||
{
|
||||
(void)0;
|
||||
// std::cout << it->server_name << " ";
|
||||
@@ -33,14 +33,16 @@ int main(int ac, char **av)
|
||||
Webserv serv;
|
||||
|
||||
// serv.init_virtual_servers();
|
||||
serv.init_virtual_servers(servers);
|
||||
delete servers;
|
||||
serv.init_virtual_servers(servers_config);
|
||||
delete servers_config;
|
||||
servers_config = NULL;
|
||||
serv.run();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
delete servers_config;
|
||||
}
|
||||
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
|
||||
#include "Webserv.hpp"
|
||||
|
||||
|
||||
void Webserv::_post(Client *client, const std::string &path)
|
||||
{
|
||||
/*
|
||||
https://www.rfc-editor.org/rfc/rfc9110.html#name-post
|
||||
*/
|
||||
void Webserv::_post(Client *client, const std::string &path)
|
||||
{
|
||||
(void)path; // unused, we use "assigned_location->upload_dir" instead
|
||||
std::cout << "_post()\n";
|
||||
std::cerr << "upload_dir = " << client->assigned_location->upload_dir << "\n";
|
||||
@@ -26,8 +25,8 @@ void Webserv::_post(Client *client, const std::string &path)
|
||||
_upload_files(client);
|
||||
}
|
||||
|
||||
// #include <ctime> // could add date to DEFAULT_NAME to avoid overwriting files
|
||||
#define DEFAULT_NAME "unnamed_file"
|
||||
// TODO : Loop for multi body
|
||||
void Webserv::_upload_files(Client *client)
|
||||
{
|
||||
std::cout << "_upload_files()\n";
|
||||
@@ -37,6 +36,7 @@ void Webserv::_upload_files(Client *client)
|
||||
std::string filename;
|
||||
size_t pos;
|
||||
bool file_existed = false;
|
||||
static int i_name = 0;
|
||||
|
||||
client->status = ::eval_file_access(client->assigned_location->upload_dir, W_OK);
|
||||
if (client->status)
|
||||
@@ -64,13 +64,10 @@ void Webserv::_upload_files(Client *client)
|
||||
filename.erase(filename.size()-1, 1);
|
||||
std::cerr << "filename ="<< filename << "\n";
|
||||
std::cerr << "filename ="<< filename << "\n";
|
||||
if (filename.empty())
|
||||
filename = DEFAULT_NAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = DEFAULT_NAME;
|
||||
}
|
||||
if (pos == NPOS || filename.empty())
|
||||
filename = DEFAULT_NAME + ::itos(i_name++);
|
||||
|
||||
std::cerr << "filename ="<< filename << "\n";
|
||||
path = client->assigned_location->upload_dir; // Assume there a final '/'
|
||||
path.append(filename);
|
||||
|
||||
Reference in New Issue
Block a user