ok, so we added a lot more checks for the config file, and some post processing, still needs a few more things, but now some defaults are set too, basically it works under most circumstances
This commit is contained in:
@@ -26,47 +26,56 @@ class ServerConfig
|
||||
{
|
||||
public:
|
||||
|
||||
// i mean i guess i need some canonic stuff?
|
||||
// although maybe if i make it a struct i can barebones it?
|
||||
// do i need some canonic stuff?
|
||||
|
||||
|
||||
std::string server_name;
|
||||
std::string root;
|
||||
|
||||
std::vector<std::string> index;
|
||||
std::map<int, std::string> error_pages;
|
||||
// there can be several
|
||||
std::vector<std::string> server_name;
|
||||
// we could shove default in here if we wanted to...
|
||||
|
||||
// i'm tempted to do something diff for storing method types...
|
||||
std::vector<MethodType> allow_methods;
|
||||
|
||||
std::vector<LocationConfig> locations;
|
||||
|
||||
// might do something diff
|
||||
struct timeval send_timeout;
|
||||
struct timeval recv_timeout;
|
||||
|
||||
int client_body_limit; // set to default max if none set
|
||||
bool autoindex;
|
||||
|
||||
// not sure what these look like in config file
|
||||
int redirect_status;
|
||||
std::string redirect_uri;
|
||||
|
||||
// is this the best way?
|
||||
// there can only be 1 per server...
|
||||
std::string host;
|
||||
std::string port; // port needs to be something else... not quite an int
|
||||
// should a Server be able to handle several?
|
||||
|
||||
// there can only be one.
|
||||
std::string root;
|
||||
|
||||
int client_body_limit; // set to default max if none set
|
||||
|
||||
// might be the only one we let slide if bad input...
|
||||
bool autoindex;
|
||||
|
||||
// we will check the index in the post processing with access() ?
|
||||
std::vector<std::string> index;
|
||||
std::map<int, std::string> error_pages;
|
||||
|
||||
// i'm tempted to do something diff for storing method types...
|
||||
// fuck it, you can only call allow_methods once in Server
|
||||
// once more in each location.
|
||||
std::vector<MethodType> allow_methods;
|
||||
|
||||
std::vector<LocationConfig> locations;
|
||||
|
||||
// not convinced we need these...
|
||||
// struct timeval send_timeout;
|
||||
// struct timeval recv_timeout;
|
||||
|
||||
|
||||
// do i need a print all for testing?
|
||||
// fuck maybe i do need return here...
|
||||
// wait if i can call several times, shouldn't it be a map?
|
||||
// i think actually there can only be 1 and it can only be in a location?
|
||||
// int redirect_status;
|
||||
// std::string redirect_uri;
|
||||
|
||||
|
||||
|
||||
void print_all()
|
||||
{
|
||||
std::cout << "PRINTING A FULL SERVER CONFIG\n\n";
|
||||
|
||||
std::cout << "Server_name: " << server_name << '\n';
|
||||
for (size_t i = 0; i < server_name.size(); i++)
|
||||
std::cout << server_name[i] << " ";
|
||||
std::cout << "root: " << root << '\n';
|
||||
std::cout << "index: ";
|
||||
for (size_t i = 0; i < index.size(); i++)
|
||||
@@ -84,8 +93,8 @@ public:
|
||||
std::cout << "also skiping send_timeout and recv\n";
|
||||
std::cout << "autoindex: " << autoindex << '\n';
|
||||
std::cout << "client_body_limit: " << client_body_limit << '\n';
|
||||
std::cout << "redirect_status: " << redirect_status << '\n';
|
||||
std::cout << "redirect_uri: " << redirect_uri << '\n';
|
||||
// std::cout << "redirect_status: " << redirect_status << '\n';
|
||||
// std::cout << "redirect_uri: " << redirect_uri << '\n';
|
||||
std::cout << "host: " << host << '\n';
|
||||
std::cout << "port: " << port << '\n';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user