Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

83 autoindex fix home #88

Merged
merged 3 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/HTTPResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ std::string HTTPResponse::buildDirIndexRes(DIR* directory,
}
}
res += "</pre><hr/></body></html>";
while (res.find("//") != std::string::npos) {
res = res.erase(res.find("//"), 1);
}
return res;
}

Expand Down
4 changes: 1 addition & 3 deletions src/parser/LocationSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ LocationSettings::LocationSettings()
default_("index.html"),
auto_index_(false),
allow_upload_(false),
upload_dir_("./www/uploads") {
allowed_methods_.push_back("GET");
}
upload_dir_("./www/uploads") {}

LocationSettings::~LocationSettings() {}

Expand Down
2 changes: 2 additions & 0 deletions src/parser/LocationSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "ASettings.hpp"

class LocationSettings : public ASettings {
friend class Settings;

public:
LocationSettings();
virtual ~LocationSettings();
Expand Down
9 changes: 8 additions & 1 deletion src/parser/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@ Settings::Settings(std::string& config_path) {
ServerSettings default_server;
this->servers.push_back(default_server);
}
// in case a server has no route create a default one
// in case a server has no route create a default one, no allowed method
// specified ? add GET as default
for (std::vector<ServerSettings>::iterator it = this->servers.begin();
it != this->servers.end(); ++it) {
if (it->getRoutes().size() == 0) {
LocationSettings default_location;
it->locations.push_back(default_location);
}
for (std::vector<LocationSettings>::iterator lt = it->locations.begin();
lt != it->locations.end(); ++lt) {
if (lt->allowed_methods_.empty()) {
lt->allowed_methods_.push_back("GET");
}
}
}
}

Expand Down
Loading