🔨」 fix: fixed first segfault

This commit is contained in:
2025-04-22 15:34:13 +02:00
parent 7abe04bf44
commit 5d1c3910bc
9 changed files with 28 additions and 17 deletions

View File

@ -6,13 +6,13 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/14 12:20:06 by adjoly #+# #+# */ /* Created: 2025/04/14 12:20:06 by adjoly #+# #+# */
/* Updated: 2025/04/22 11:52:33 by mmoussou ### ########.fr */ /* Updated: 2025/04/22 15:25:39 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#pragma once #pragma once
#include <config/default.hpp> #include <config/Server.hpp>
namespace webserv { namespace webserv {
namespace config { namespace config {

View File

@ -6,14 +6,14 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:11:28 by adjoly #+# #+# */ /* Created: 2025/03/19 14:11:28 by adjoly #+# #+# */
/* Updated: 2025/04/22 14:25:17 by adjoly ### ########.fr */ /* Updated: 2025/04/22 15:25:58 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#pragma once #pragma once
#include <webserv.hpp> #include <webserv.hpp>
#include <config/default.hpp> #include <config/Route.hpp>
#include <cppeleven.hpp> #include <cppeleven.hpp>
#include <node/ANode.hpp> #include <node/ANode.hpp>
#include <webserv.hpp> #include <webserv.hpp>

View File

@ -6,15 +6,15 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:15:51 by adjoly #+# #+# */ /* Created: 2025/03/19 14:15:51 by adjoly #+# #+# */
/* Updated: 2025/04/22 12:40:20 by adjoly ### ########.fr */ /* Updated: 2025/04/22 15:28:31 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#pragma once #pragma once
#include <config/Config.hpp>
#include <config/Route.hpp> #include <config/Route.hpp>
#include <config/Server.hpp> #include <config/Server.hpp>
#include <config/Config.hpp>
#include <cppeleven.hpp> #include <cppeleven.hpp>
#include <node/Table.hpp> #include <node/Table.hpp>
#include <node/default.hpp> #include <node/default.hpp>
@ -41,7 +41,7 @@ static inline void *accessValue(const std::string &name, toml::nodeType type,
if (table == not_nullptr) if (table == not_nullptr)
return not_nullptr; return not_nullptr;
val = dynamic_cast<toml::Table *>(table)->access(name, type, found); val = dynamic_cast<toml::ANode *>(table)->access(name, type, found);
if (found == true && val != not_nullptr) { if (found == true && val != not_nullptr) {
return val; return val;
} else { } else {

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */ /* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/11 22:13:38 by mmoussou #+# #+# */ /* Created: 2025/02/11 22:13:38 by mmoussou #+# #+# */
/* Updated: 2025/04/22 11:52:05 by mmoussou ### ########.fr */ /* Updated: 2025/04/22 15:00:18 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */ /* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 17:23:00 by mmoussou #+# #+# */ /* Created: 2025/02/03 17:23:00 by mmoussou #+# #+# */
/* Updated: 2025/04/22 11:52:16 by mmoussou ### ########.fr */ /* Updated: 2025/04/22 15:07:02 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,10 +6,11 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/14 12:53:54 by adjoly #+# #+# */ /* Created: 2025/04/14 12:53:54 by adjoly #+# #+# */
/* Updated: 2025/04/22 14:31:34 by adjoly ### ########.fr */ /* Updated: 2025/04/22 15:32:19 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "node/default.hpp"
#include "webserv.hpp" #include "webserv.hpp"
#include "cppeleven.hpp" #include "cppeleven.hpp"
#include "node/ANode.hpp" #include "node/ANode.hpp"
@ -33,9 +34,11 @@ Config::Config(std::string &filename) {
std::map<std::string, toml::ANode *> *node = table->getTable(); std::map<std::string, toml::ANode *> *node = table->getTable();
for (auto it = prange(node)) { for (auto it = prange(node)) {
if (it->second->type() == toml::TABLE) {
Server *srv = new Server(it->second); Server *srv = new Server(it->second);
_servers.push_back(srv); _servers.push_back(srv);
} }
}
delete table; delete table;
delete file; delete file;
} }

View File

@ -6,18 +6,22 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/24 15:10:07 by adjoly #+# #+# */ /* Created: 2025/03/24 15:10:07 by adjoly #+# #+# */
/* Updated: 2025/04/22 14:26:00 by adjoly ### ########.fr */ /* Updated: 2025/04/22 15:25:06 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include <webserv.hpp> #include "cppeleven.hpp"
#include <config/default.hpp> #include <config/default.hpp>
#include <webserv.hpp>
using namespace webserv::config; using namespace webserv::config;
Server::Server(toml::ANode *node) : _table(node) { Server::Server(toml::ANode *node) : _table(node) {
bool found; bool found;
if (_table == not_nullptr)
return;
// host parsing // host parsing
void *host = accessValue("host", toml::STRING, _table, _log); void *host = accessValue("host", toml::STRING, _table, _log);
if (host != not_nullptr) { if (host != not_nullptr) {

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */ /* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 15:45:07 by mmoussou #+# #+# */ /* Created: 2025/02/03 15:45:07 by mmoussou #+# #+# */
/* Updated: 2025/04/22 14:50:32 by adjoly ### ########.fr */ /* Updated: 2025/04/22 14:52:44 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */ /* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 16:07:01 by mmoussou #+# #+# */ /* Created: 2025/02/03 16:07:01 by mmoussou #+# #+# */
/* Updated: 2025/04/20 11:15:51 by mmoussou ### ########.fr */ /* Updated: 2025/04/22 15:03:46 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,6 +20,10 @@
using namespace webserv; using namespace webserv;
http::IRequest::~IRequest(void) {
}
std::string http::IRequest::str(void) const std::string http::IRequest::str(void) const
{ {
std::ostringstream response; std::ostringstream response;