Location sorter works, fixed the compilation error i was having on this branch, now working on autoindex

This commit is contained in:
Me
2022-08-07 03:24:49 +02:00
parent 4b1baca126
commit 4870b2c05d
6 changed files with 45 additions and 53 deletions

View File

@@ -143,6 +143,10 @@ void Webserv::_get(Client *client, ServerConfig &server, LocationConfig &locatio
std::cerr << "path = " << path << "\n";
std::cout << "ERIC path: " << path << '\n';
// if (path_is_valid(
// TMP HUGO
//
if (_is_cgi(client))
@@ -156,6 +160,30 @@ void Webserv::_get(Client *client, ServerConfig &server, LocationConfig &locatio
_get_file(client, path);
}
// i might need some sort of _generate_autoindex()
void Webserv::_autoindex(Client *client, std::string &path)
{
// i think the plan is to generate an html file and return it
// it should be filled with the stuff that is found in that repo
// either i create a tmp file and put the html in it an call
// the _get_file on it with a new path...
// or i make the html and do what _get_file does if it found
// a valid file...
// Let's try the 2nd one first.
// if successful we call _append_body
}
void Webserv::_get_file(Client *client, const std::string &path)
{
std::ifstream ifd; // For chunk, ifstream directly in struct CLient for multiples read without close() ?
@@ -223,6 +251,7 @@ void Webserv::_get_file(Client *client, const std::string &path)
}
}
void Webserv::_append_body(Client *client, const char *body, size_t body_size, const std::string &file_extension)
{
/*
@@ -385,13 +414,6 @@ ServerConfig &Webserv::_determine_process_server(Client *client)
LocationConfig &Webserv::_determine_location(ServerConfig &server, std::string &path)
{
/*
Assume there is at least one location in vector<LocationConfig> for path "/"
TODO in ConfigParser :
If no location block in config file, one need to be generated
for path "/", and filled with fields "root" and "index" based on parent server block
*/
std::vector<LocationConfig>::iterator it = server.locations.begin();
while (it != server.locations.end())
{