mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-06-25 09:33:36 +02:00
「🏗️」 wip: now clearing client resource at sigint
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/13 18:14:45 by adjoly #+# #+# */
|
/* Created: 2025/05/13 18:14:45 by adjoly #+# #+# */
|
||||||
/* Updated: 2025/05/29 11:34:40 by adjoly ### ########.fr */
|
/* Updated: 2025/05/29 12:07:56 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -30,7 +30,6 @@ class CgiIn : public AClientResource {
|
|||||||
}
|
}
|
||||||
~CgiIn(void) {
|
~CgiIn(void) {
|
||||||
log("➖", "CgiIn", "destructor called");
|
log("➖", "CgiIn", "destructor called");
|
||||||
close(_fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void process(void) {
|
void process(void) {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/12 17:13:39 by adjoly #+# #+# */
|
/* Created: 2025/05/12 17:13:39 by adjoly #+# #+# */
|
||||||
/* Updated: 2025/05/27 18:40:54 by adjoly ### ########.fr */
|
/* Updated: 2025/05/29 12:08:41 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -81,6 +81,12 @@ class ResourceManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clear(void) {
|
||||||
|
for (auto it = range (_res)) {
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
private:
|
private:
|
||||||
static std::vector<AClientResource *> _res;
|
static std::vector<AClientResource *> _res;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/30 09:50:20 by adjoly #+# #+# */
|
/* Created: 2025/04/30 09:50:20 by adjoly #+# #+# */
|
||||||
/* Updated: 2025/05/29 11:44:46 by adjoly ### ########.fr */
|
/* Updated: 2025/05/29 12:06:54 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
using namespace webserv::http;
|
using namespace webserv::http;
|
||||||
|
|
||||||
|
Response parseCgiOut(std::string cgi_str);
|
||||||
|
|
||||||
Post::Post(std::string &data, config::Server *srv) {
|
Post::Post(std::string &data, config::Server *srv) {
|
||||||
_url = not_nullptr;
|
_url = not_nullptr;
|
||||||
_srv = srv;
|
_srv = srv;
|
||||||
@ -52,6 +54,8 @@ void Post::parse(std::string const &data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_route = _srv->whatRoute(URL(_target));
|
||||||
|
|
||||||
std::ostringstream body_stream;
|
std::ostringstream body_stream;
|
||||||
while (std::getline(stream, line))
|
while (std::getline(stream, line))
|
||||||
body_stream << line << "\n";
|
body_stream << line << "\n";
|
||||||
@ -118,34 +122,6 @@ void Post::handleMultipartData(const std::string &body,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Response parseCgiOut(std::string cgi_str) {
|
|
||||||
Response response;
|
|
||||||
std::istringstream stream(cgi_str);
|
|
||||||
std::string line;
|
|
||||||
|
|
||||||
response.setStatusCode(200);
|
|
||||||
while (std::getline(stream, line) && line != "") {
|
|
||||||
size_t delimiter_index = line.find(':');
|
|
||||||
if (delimiter_index != std::string::npos) {
|
|
||||||
std::string key = line.substr(0, delimiter_index);
|
|
||||||
std::string value = line.substr(delimiter_index + 2);
|
|
||||||
response.addHeader(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::ostringstream body_stream;
|
|
||||||
while (std::getline(stream, line))
|
|
||||||
body_stream << line << "\n";
|
|
||||||
response.setBody(body_stream.str());
|
|
||||||
|
|
||||||
if (response.getHeader("Content-Length") == "") {
|
|
||||||
std::stringstream length;
|
|
||||||
length << response.getBody().length();
|
|
||||||
response.addHeader("Content-Length", length.str());
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Response Post::execute(void) {
|
Response Post::execute(void) {
|
||||||
http::Response response;
|
http::Response response;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/11 16:11:40 by adjoly #+# #+# */
|
/* Created: 2025/04/11 16:11:40 by adjoly #+# #+# */
|
||||||
/* Updated: 2025/05/28 10:59:27 by adjoly ### ########.fr */
|
/* Updated: 2025/05/29 12:07:43 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -159,4 +159,5 @@ Server::~Server(void) {
|
|||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
PfdManager::clear();
|
PfdManager::clear();
|
||||||
|
ResourceManager::clear();
|
||||||
}
|
}
|
||||||
|
BIN
vgcore.111739
Normal file
BIN
vgcore.111739
Normal file
Binary file not shown.
BIN
vgcore.111861
Normal file
BIN
vgcore.111861
Normal file
Binary file not shown.
Reference in New Issue
Block a user