autoindex in progress but need to check stuff on master branch
This commit is contained in:
@@ -105,8 +105,6 @@ ServerConfig ConfigParser::_parse_server(size_t *start)
|
||||
size_t curr = _content.find_first_not_of(" \t\n", *start);
|
||||
|
||||
ret.client_body_limit = 0;
|
||||
ret.autoindex = false;
|
||||
ret.allow_methods = 0;
|
||||
if (curr == std::string::npos || _content[curr] != '{')
|
||||
throw std::invalid_argument("bad config file syntax 1");
|
||||
|
||||
@@ -144,7 +142,7 @@ LocationConfig ConfigParser::_parse_location(size_t *start)
|
||||
size_t curr = *start;
|
||||
// start is after the 1st word aka "location"
|
||||
|
||||
ret.client_body_limit = 0;
|
||||
ret.autoindex = false;
|
||||
ret.redirect_status = 0;
|
||||
ret.allow_methods = 0;
|
||||
|
||||
@@ -243,12 +241,6 @@ void ConfigParser::_set_server_values(ServerConfig *server, \
|
||||
else
|
||||
throw std::invalid_argument("Root dir invalid 1");
|
||||
}
|
||||
else if (key == "autoindex" && size == 1)
|
||||
{
|
||||
// autoindex is a bool, there's no good way for me to see if it has
|
||||
// bet set already
|
||||
server->autoindex = (tmp_val[0] == "on" ? true : false);
|
||||
}
|
||||
else if (key == "client_body_limit" && size == 1 \
|
||||
&& server->client_body_limit == 0)
|
||||
{
|
||||
@@ -265,16 +257,6 @@ void ConfigParser::_set_server_values(ServerConfig *server, \
|
||||
for (unsigned long i = 0; i != tmp_val.size(); i++)
|
||||
server->index.push_back(tmp_val[i]);
|
||||
}
|
||||
else if (key == "allow_methods" && server->allow_methods == 0)
|
||||
{
|
||||
for (unsigned long i = 0; i != tmp_val.size(); i++)
|
||||
{
|
||||
http_method m = ::str_to_http_method(tmp_val[i]);
|
||||
if (m == UNKNOWN)
|
||||
throw std::invalid_argument("not a valid method");
|
||||
server->allow_methods |= m;
|
||||
}
|
||||
}
|
||||
else if (key == "error_page")
|
||||
{
|
||||
|
||||
@@ -329,12 +311,9 @@ void ConfigParser::_set_location_values(LocationConfig *location, \
|
||||
else
|
||||
throw std::invalid_argument("Root dir invalid");
|
||||
}
|
||||
else if (key == "client_body_limit" && size == 1 \
|
||||
&& location->client_body_limit == 0)
|
||||
else if (key == "autoindex" && size == 1)
|
||||
{
|
||||
if (!::isNumeric(tmp_val[0]))
|
||||
throw std::invalid_argument("client_body_limit not a number");
|
||||
location->client_body_limit = atoi(tmp_val[0].c_str());
|
||||
location->autoindex = (tmp_val[0] == "on" ? true : false);
|
||||
}
|
||||
else if (key == "index")
|
||||
{
|
||||
@@ -352,18 +331,16 @@ void ConfigParser::_set_location_values(LocationConfig *location, \
|
||||
location->allow_methods |= m;
|
||||
}
|
||||
}
|
||||
else if (key == "cgi_info")
|
||||
else if (key == "cgi_ext")
|
||||
{
|
||||
// you can call cgi_info several times i think.
|
||||
// ok wtf is all this even doing, figure that out
|
||||
unsigned long i = value.find_first_of(" ");
|
||||
if (i == std::string::npos)
|
||||
throw std::invalid_argument("bad config file arguments 8");
|
||||
// ok why an int now, we gotta be more consistent!
|
||||
int j = value.find_first_not_of(" ", i);
|
||||
location->cgi_info[value.substr(0, i)] = value.substr(j, value.length());
|
||||
for (size_t i = 0; i < tmp_val.size(); i++)
|
||||
{
|
||||
if (tmp_val[i][0] == '.')
|
||||
throw std::invalid_argument("cgi_ext should not have a leading '.'");
|
||||
location->cgi_ext.push_back(tmp_val[i]);
|
||||
}
|
||||
}
|
||||
else if (key == "return" && location->redirect_status == 0 \
|
||||
else if (key == "redirect" && location->redirect_status == 0 \
|
||||
&& location->redirect_uri == "")
|
||||
{
|
||||
// actually i think there can only be one per location...
|
||||
|
||||
Reference in New Issue
Block a user