mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-06-25 09:33:36 +02:00
「🏗️」 wip: reformated request include folder
This commit is contained in:
@ -1,42 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Resource.cpp :+: :+: :+: */
|
||||
/* AResource.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/29 14:42:01 by mmoussou #+# #+# */
|
||||
/* Updated: 2025/04/29 14:56:53 by mmoussou ### ########.fr */
|
||||
/* Updated: 2025/04/29 15:45:19 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <server/Resource.hpp>
|
||||
|
||||
/*
|
||||
class ClientResource {
|
||||
public:
|
||||
virtual void handleResource() = 0;
|
||||
virtual ~HttpClientResource() {}
|
||||
|
||||
void addFileDescriptor(int fd);
|
||||
void getFileDescriptors();
|
||||
|
||||
private:
|
||||
struct pollfd fd;
|
||||
|
||||
}
|
||||
*/
|
||||
#include <server/AResource.hpp>
|
||||
|
||||
using namespace webserv;
|
||||
using namespace server;
|
||||
|
||||
void ClientResource::addFileDescriptor(struct pollfd fd)
|
||||
void AClientResource::addFileDescriptor(struct pollfd fd)
|
||||
{
|
||||
this->_fd = fd;
|
||||
}
|
||||
|
||||
|
||||
struct pollfd ClientResource::getFileDescriptor()
|
||||
struct pollfd AClientResource::getFileDescriptor()
|
||||
{
|
||||
return (this->_fd);
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/17 11:12:41 by mmoussou #+# #+# */
|
||||
/* Updated: 2025/04/29 14:24:31 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/04/29 17:27:49 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -20,7 +20,7 @@ using namespace webserv::server;
|
||||
Client::Client(struct pollfd *pfd, sockaddr_in socket, config::Config *conf)
|
||||
: _pfd(pfd), _client_addr(socket), _Gconf(conf) {
|
||||
_request = not_nullptr;
|
||||
//log("➕", "Client", "constructor called");
|
||||
log("➕", "Client", "constructor called");
|
||||
}
|
||||
|
||||
Client::Client(const Client &cpy) {
|
||||
@ -34,7 +34,6 @@ void Client::parse(void) {
|
||||
char buffer[BUFFER_SIZE];
|
||||
ssize_t bytes_received;
|
||||
|
||||
|
||||
do {
|
||||
std::memset(buffer, 0, BUFFER_SIZE);
|
||||
bytes_received = recv(_pfd->fd, buffer, BUFFER_SIZE - 1, 0);
|
||||
@ -102,6 +101,6 @@ void Client::answer(void) {
|
||||
}
|
||||
|
||||
Client::~Client(void) {
|
||||
//log("➖", "Client", "destructor called");
|
||||
log("➖", "Client", "destructor called");
|
||||
delete (http::Get *)(this->_request);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/11 16:11:40 by adjoly #+# #+# */
|
||||
/* Updated: 2025/04/29 14:27:42 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/04/29 17:28:17 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -102,7 +102,7 @@ void Server::_run(void) {
|
||||
fd.fd = *it;
|
||||
fd.events = POLLIN;
|
||||
_client_fds.push_back(fd);
|
||||
//_log->debug("new socket in poll");
|
||||
_log->debug("new socket in poll");
|
||||
}
|
||||
|
||||
// to add signal instead of 727
|
||||
@ -172,10 +172,9 @@ void Server::_run(void) {
|
||||
_log->error("client does not exist");
|
||||
continue;
|
||||
}
|
||||
if (client->requestParsed() == false) {
|
||||
continue;
|
||||
if (client->requestParsed() == true) {
|
||||
client->answer();
|
||||
}
|
||||
client->answer();
|
||||
_client_data.erase(std::find(_client_data.begin(),
|
||||
_client_data.end(), client));
|
||||
delete client;
|
||||
@ -194,7 +193,7 @@ void Server::_run(void) {
|
||||
}
|
||||
|
||||
Server::Server(config::Config *conf) : _conf(conf) {
|
||||
// log("➕", "Server::Server", "config constructor called");
|
||||
log("➕", "Server::Server", "config constructor called");
|
||||
_log = conf->getLogger();
|
||||
try {
|
||||
_setup();
|
||||
@ -205,7 +204,7 @@ Server::Server(config::Config *conf) : _conf(conf) {
|
||||
}
|
||||
|
||||
Server::~Server(void) {
|
||||
// log("➖", "Server::Server", "destructor called");
|
||||
log("➖", "Server::Server", "destructor called");
|
||||
for (std::vector<struct pollfd>::iterator it = _client_fds.begin();
|
||||
it != _client_fds.end(); it++)
|
||||
close(it->fd);
|
||||
|
Reference in New Issue
Block a user