🏗️」 wip: reformated request include folder

This commit is contained in:
2025-04-30 09:37:21 +02:00
parent 5a22af3c5a
commit 41efd2c19e
15 changed files with 315 additions and 343 deletions

View File

@ -0,0 +1,61 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ARequest.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 17:23:00 by mmoussou #+# #+# */
/* Updated: 2025/04/30 09:34:49 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include "config/URL.hpp"
#include <ctime>
#include <fstream>
#include <iostream>
#include <sstream>
#include <requests/IMessage.hpp>
#include <requests/Mime.hpp>
#include <requests/Response.hpp>
#include <config/default.hpp>
namespace webserv {
namespace http {
class ARequest : public http::IMessage {
public:
virtual ~ARequest(void) {
log("", "ARequest", "destructor called");
delete _url;
}
virtual void parse(std::string const &data) = 0;
virtual Response execute(void) = 0;
std::string str(void) const;
std::string getMethod(void) const;
std::string getTarget(void) const;
std::string getProtocol(void) const;
config::Server *getConfig(void) const;
void setMethod(std::string const method);
void setTarget(std::string const target);
void setProtocol(std::string const protocol);
void setServer(std::string const protocol);
protected:
std::string _method;
std::string _target;
std::string _protocol;
config::Server *_conf;
URL *_url;
};
} // namespace http
} // namespace webserv

View File

@ -6,14 +6,13 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/24 14:17:34 by adjoly #+# #+# */
/* Updated: 2025/04/25 13:40:10 by adjoly ### ########.fr */
/* Updated: 2025/04/30 09:36:02 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include "requests/HttpIMessage.hpp"
#include "requests/HttpRequest.hpp"
#include <requests/ARequest.hpp>
#include <config/default.hpp>
#include <map>
#include <string>
@ -22,7 +21,7 @@ namespace webserv {
class Cgi {
public:
Cgi(http::IRequest *, config::Server *);
Cgi(http::ARequest *, config::Server *);
~Cgi(void);
std::string getEnv(std::string &);

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/16 17:51:46 by mmoussou #+# #+# */
/* Updated: 2025/04/24 14:56:08 by mmoussou ### ########.fr */
/* Updated: 2025/04/30 09:35:21 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,7 +15,7 @@
#include <map>
#include <string>
#include <requests/HttpResponse.hpp>
#include <requests/Response.hpp>
namespace webserv {
namespace http {

View File

@ -1,93 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* HttpRequest.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 17:23:00 by mmoussou #+# #+# */
/* Updated: 2025/04/24 15:09:52 by mmoussou ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <ctime>
#include <fstream>
#include <sstream>
#include <iostream>
#include <requests/HttpIMessage.hpp>
#include <requests/HttpResponse.hpp>
#include <requests/Mime.hpp>
#include <config/default.hpp>
namespace webserv {
namespace http {
class IRequest: public http::IMessage {
public:
virtual ~IRequest(void);
virtual void parse(std::string const &data) = 0;
virtual http::Response execute(void) = 0;
std::string str(void) const;
std::string getMethod(void) const;
std::string getTarget(void) const;
std::string getProtocol(void) const;
config::Server *getConfig(void) const;
void setMethod(std::string const method);
void setTarget(std::string const target);
void setProtocol(std::string const protocol);
void setServer(std::string const protocol);
protected:
std::string _method;
std::string _target;
std::string _protocol;
config::Server *_conf;
};
class Get: public http::IRequest {
public:
Get(void);
~Get(void);
Get(std::string &data);
void parse(std::string const &data);
http::Response execute(void);
};
class Post: public http::IRequest {
public:
Post(void);
~Post(void);
Post(std::string &data);
void parse(std::string const &data);
http::Response execute(void);
};
class Delete: public http::IRequest {
public:
Delete(void);
~Delete(void);
Delete(std::string &data);
void parse(std::string const &data);
http::Response execute(void);
};
} // -namespace http
} // -namespace webserv

View File

@ -0,0 +1,49 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* RequestImplement.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/30 09:30:15 by adjoly #+# #+# */
/* Updated: 2025/04/30 09:34:17 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <requests/ARequest.hpp>
namespace webserv {
namespace http {
class Get : public ARequest {
public:
Get(void) {}
Get(std::string &data);
void parse(std::string const &data);
Response execute(void);
};
class Post : public ARequest {
public:
Post(void) {}
Post(std::string &data);
void parse(std::string const &data);
Response execute(void);
};
class Delete : public http::ARequest {
public:
Delete(void) {}
Delete(std::string &data);
void parse(std::string const &data);
Response execute(void);
};
}; // namespace http
}; // namespace webserv

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* HttpResponse.hpp :+: :+: :+: */
/* Response.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 17:21:20 by mmoussou #+# #+# */
/* Updated: 2025/04/23 14:36:47 by mmoussou ### ########.fr */
/* Updated: 2025/04/30 09:33:47 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,33 +14,32 @@
#include <sstream>
#include <requests/HttpIMessage.hpp>
#include <requests/IMessage.hpp>
typedef unsigned int uint;
namespace webserv {
namespace http {
class Response: public http::IMessage {
public:
class Response : public http::IMessage {
public:
Response(void);
~Response(void);
std::string getProtocol(void) const;
std::string getProtocol(void) const;
uint getStatusCode(void) const;
std::string getStatusText(void) const;
std::string getStatusText(void) const;
void setProtocol(std::string const protocol);
void setStatusCode(uint const status_code);
void setProtocol(std::string const protocol);
void setStatusCode(uint const status_code);
std::string str(void) const;
std::string str(void) const;
private:
std::string _protocol;
private:
std::string _protocol;
uint _status_code;
std::string _status_text;
std::string _status_text;
};
} // -namespace http
} // -namespace webserv
} // namespace http
} // namespace webserv

View File

@ -6,15 +6,21 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 15:48:22 by mmoussou #+# #+# */
/* Updated: 2025/04/24 13:48:09 by adjoly ### ########.fr */
/* Updated: 2025/04/30 09:36:57 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <requests/Errors.hpp>
#include <requests/HttpRequest.hpp>
#include <requests/HttpResponse.hpp>
#include <requests/ARequest.hpp>
#include <requests/Cgi.hpp>
#include <requests/Errors.hpp>
#include <requests/IMessage.hpp>
#include <requests/Mime.hpp>
#include <requests/RequestImplement.hpp>
#include <requests/Response.hpp>
namespace webserv {
};
using namespace webserv;