a few more things for location picker
This commit is contained in:
@@ -232,8 +232,9 @@ void ConfigParser::_set_server_values(ServerConfig *server, \
|
||||
else if (key == "root" && size == 1 && server->root == "")
|
||||
{
|
||||
// remove trailing /
|
||||
if (tmp_val[0][tmp_val[0].size() - 1] == '/')
|
||||
tmp_val[0].erase(tmp_val[0].size() - 1, 1);
|
||||
if (tmp_val[0][tmp_val[0].size() - 1] != '/')
|
||||
tmp_val[0].push_back('/');
|
||||
// tmp_val[0].erase(tmp_val[0].size() - 1, 1);
|
||||
server->root = tmp_val[0];
|
||||
}
|
||||
else if (key == "client_body_limit" && size == 1 \
|
||||
@@ -280,9 +281,10 @@ void ConfigParser::_set_location_values(LocationConfig *location, \
|
||||
throw std::invalid_argument("missing value");
|
||||
else if (key == "root" && size == 1 && location->root == "")
|
||||
{
|
||||
// remove trailing /
|
||||
if (tmp_val[0][tmp_val[0].size() - 1] == '/')
|
||||
tmp_val[0].erase(tmp_val[0].size() - 1, 1);
|
||||
// add trailing /
|
||||
if (tmp_val[0][tmp_val[0].size() - 1] != '/')
|
||||
tmp_val[0].push_back('/');
|
||||
// tmp_val[0].erase(tmp_val[0].size() - 1, 1);
|
||||
location->root = tmp_val[0];
|
||||
}
|
||||
else if (key == "autoindex" && size == 1)
|
||||
|
||||
@@ -52,7 +52,8 @@ void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
|
||||
if (it_l->allow_methods == UNKNOWN)
|
||||
it_l->allow_methods = ANY_METHODS;
|
||||
|
||||
if (it_l->index.empty())
|
||||
// also
|
||||
if (it_l->index.empty() && it_l->autoindex == false)
|
||||
it_l->index = it->index;
|
||||
|
||||
// nothing to be done for cgi_ext, error_pages, redirect
|
||||
|
||||
@@ -11,12 +11,16 @@ if file, server that!
|
||||
|
||||
Where does cgi fit in in all this ???
|
||||
|
||||
|
||||
*/
|
||||
|
||||
std::string path = client->get_rq_abs_path();
|
||||
|
||||
// this might not be the best thing, a voir
|
||||
path.insert(0, client->assigned_location->root);
|
||||
// path.insert(0, client->assigned_location->root);
|
||||
|
||||
//client->assigned_location->path
|
||||
|
||||
path.replace(0, client->assigned_location->path.size(), client->assigned_location->root);
|
||||
|
||||
std::cerr << "path = " << path << "\n";
|
||||
|
||||
@@ -25,6 +29,9 @@ Where does cgi fit in in all this ???
|
||||
// or autoindex if allowed
|
||||
// or let _get_file sort out the error otherwise.
|
||||
|
||||
// change this cuz
|
||||
// if (path_is_valid(client->assigned_location->root) == 2)
|
||||
// _get_file(...);
|
||||
if (path_is_valid(path) == 1)
|
||||
{
|
||||
// std::cout << "path is valid\n";
|
||||
|
||||
@@ -248,6 +248,9 @@ if no path coresponds then use the most correct one
|
||||
if (tmp[tmp.size() - 1] != '/')
|
||||
tmp.push_back('/');
|
||||
|
||||
/test/index.html/
|
||||
/test/index.html
|
||||
|
||||
|
||||
for (std::vector<LocationConfig>::const_iterator it = server.locations.begin(); it != server.locations.end(); it++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user