mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-06-25 09:33:36 +02:00
「🔨」 fix: fixed config and remove default config table
This commit is contained in:
@ -6,15 +6,15 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/14 12:53:54 by adjoly #+# #+# */
|
||||
/* Updated: 2025/05/01 17:00:00 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/05/03 09:42:44 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cppeleven.hpp"
|
||||
#include "log.hpp"
|
||||
#include "node/ANode.hpp"
|
||||
#include "node/default.hpp"
|
||||
#include "webserv.hpp"
|
||||
#include "cppeleven.hpp"
|
||||
#include "node/ANode.hpp"
|
||||
#include <config/default.hpp>
|
||||
#include <netinet/in.h>
|
||||
#include <stdexcept>
|
||||
@ -23,7 +23,7 @@ using namespace webserv::config;
|
||||
|
||||
Config::Config(std::string &filename) {
|
||||
toml::Toml *file = new toml::Toml(filename);
|
||||
|
||||
|
||||
try {
|
||||
file->parse();
|
||||
} catch (std::runtime_error &e) {
|
||||
@ -45,21 +45,14 @@ Config::Config(std::string &filename) {
|
||||
if (it->second->type() == toml::TABLE) {
|
||||
_log->info("taking server from table : " + it->first);
|
||||
try {
|
||||
if (it->first == "default") {
|
||||
_default = new Server(it->second, not_nullptr);
|
||||
} else {
|
||||
Server *srv = new Server(it->second);
|
||||
_servers.push_back(srv);
|
||||
}
|
||||
Server *srv = new Server(it->second);
|
||||
_servers.push_back(srv);
|
||||
} catch (std::runtime_error &e) {
|
||||
_log->error(e.what());
|
||||
if (!_servers.empty()) {
|
||||
for (auto it = range(_servers))
|
||||
delete (*it);
|
||||
}
|
||||
if (_default != not_nullptr) {
|
||||
delete _default;
|
||||
}
|
||||
delete table;
|
||||
delete file;
|
||||
throw e;
|
||||
@ -74,5 +67,4 @@ Config::~Config(void) {
|
||||
for (auto it = range(_servers)) {
|
||||
delete *it;
|
||||
}
|
||||
delete _default;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/30 09:50:20 by adjoly #+# #+# */
|
||||
/* Updated: 2025/05/02 15:02:56 by mmoussou ### ########.fr */
|
||||
/* Updated: 2025/05/03 09:44:41 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -67,13 +67,13 @@ void Post::parse(std::string const &data) {
|
||||
*/
|
||||
}
|
||||
|
||||
std::string extractFilename(const std::string &header) {
|
||||
std::string Post::extractFilename(const std::string &header) {
|
||||
size_t start = header.find("filename=\"") + 10;
|
||||
size_t end = header.find("\"", start);
|
||||
return this->_route->getUpRoot() + header.substr(start, end - start);
|
||||
}
|
||||
|
||||
void handleMultipartData(const std::string &body, const std::string &boundary) {
|
||||
void Post::handleMultipartData(const std::string &body, const std::string &boundary) {
|
||||
size_t i = 0;
|
||||
std::string delim = "--" + boundary;
|
||||
delim.erase(delim.size() - 1);
|
||||
|
Reference in New Issue
Block a user