🏗️」 wip: Started fixing cgi but no clue what is happening

This commit is contained in:
2025-07-01 11:28:27 +02:00
parent 8e5f80b994
commit 36f4609a25
5 changed files with 31 additions and 20 deletions

View File

@ -6,22 +6,23 @@
/* By: gadelbes <gadelbes@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/24 13:46:34 by gadelbes #+# #+# */
/* Updated: 2025/05/27 21:32:43 by adjoly ### ########.fr */
/* Updated: 2025/07/01 11:21:31 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include "server/AResource.hpp"
#include <config/default.hpp>
#include <cstdio>
#include <server/AResource.hpp>
#include <exception>
#include <map>
#include <server/CgiIn.hpp>
#include <server/ResourceManager.hpp>
#include <sstream>
#include <string>
#include <unistd.h>
namespace webserv {
namespace http {
class Get;
@ -55,10 +56,19 @@ class Cgi : public server::AClientResource {
short event(void) const { return POLLIN; }
bool isReady(void) const {
if (_is_post == false)
if (_is_post == false) {
_log->debug("CGIIII not a post");
return true;
if (ResourceManager::get(_stdin_pipe[PIPE_WRITE])->isProcessed())
}
if (static_cast<CgiIn *>(ResourceManager::get(_stdin_pipe[PIPE_WRITE]))
->isProcessed() == true) {
std::cout << "in "
<< ResourceManager::get(_stdin_pipe[PIPE_WRITE])->getId()
<< std::endl;
std::cout << ResourceManager::get(_stdin_pipe[PIPE_WRITE])->type() << std::endl;
_log->debug("CGIIII post readyyy");
return true;
}
return false;
}

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/13 18:14:45 by adjoly #+# #+# */
/* Updated: 2025/06/23 21:25:26 by adjoly ### ########.fr */
/* Updated: 2025/07/01 11:17:52 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,9 +14,9 @@
#include "server/AResource.hpp"
#include <log.hpp>
#include <server/PfdManager.hpp>
#include <stdexcept>
#include <unistd.h>
#include <server/PfdManager.hpp>
namespace webserv {
namespace server {
@ -34,6 +34,7 @@ class CgiIn : public AClientResource {
~CgiIn(void) { log("", "CgiIn", "destructor called"); }
void process(void) {
std::cout << "process" << std::endl;
_processed = true;
ssize_t bytes_written = write(_fd, _body.c_str(), _body.size());
_log->debug("writting body : " + _body);
@ -49,7 +50,10 @@ class CgiIn : public AClientResource {
}
clientResType type(void) const { return CGI_IN; }
short event(void) const { return POLLIN; }
bool isReady(void) const { return true; }
bool isReady(void) const {
_log->debug("CgiIn ready");
return true;
}
protected:
private: