mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-05-11 00:08:46 +02:00
「🏗️」 wip(includes): very very wip of the headers (this commit should be deleted later)
This commit is contained in:
@ -6,22 +6,78 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/03 17:23:00 by mmoussou #+# #+# */
|
||||
/* Updated: 2025/02/03 18:11:29 by mmoussou ### ########.fr */
|
||||
/* Updated: 2025/02/11 13:49:50 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#ifndef __REQUESTS_HTTP_REQUEST_HPP__
|
||||
# define __REQUESTS_HTTP_REQUEST_HPP__
|
||||
#ifndef __WEBSERV_REQUESTS_HTTP_REQUEST_HPP__
|
||||
# define __WEBSERV_REQUESTS_HTTP_REQUEST_HPP__
|
||||
|
||||
#include "requests/default.hpp"
|
||||
|
||||
namespace webserv {
|
||||
namespace http {
|
||||
|
||||
class IRequest: public http::IMessage {
|
||||
public:
|
||||
virtual void parse(const http::IRequest &request) = 0;
|
||||
virtual http::Response execute(void) = 0;
|
||||
|
||||
std::string str(void) const;
|
||||
|
||||
std::string getProtocol(void) const;
|
||||
size_t getStatusCode(void) const;
|
||||
std::string getStatusText(void) const;
|
||||
|
||||
void setProtocol(std::string const protocol);
|
||||
void setStatusCode(size_t const status_code);
|
||||
void setStatusText(std::string const status_text);
|
||||
|
||||
private:
|
||||
std::string _method;
|
||||
std::string _target;
|
||||
std::string _protocol;
|
||||
|
||||
struct HttpRequest {
|
||||
std::string method;
|
||||
std::string target;
|
||||
std::string protocol;
|
||||
std::map<std::string, std::string> headers;
|
||||
std::string body;
|
||||
};
|
||||
|
||||
HttpRequest parseRequest(const std::string &rawRequest);
|
||||
class Get: public http::IRequest {
|
||||
public:
|
||||
Get(void);
|
||||
Get(std::string &data);
|
||||
~Get(void);
|
||||
|
||||
#endif
|
||||
void parse(const http::IRequest &request);
|
||||
|
||||
http::Response execute(void);
|
||||
|
||||
};
|
||||
|
||||
class Post: public http::IRequest {
|
||||
public:
|
||||
Post(void);
|
||||
Post(std::string &data);
|
||||
~Post(void);
|
||||
|
||||
void parse(const http::IRequest &request);
|
||||
|
||||
http::Response execute(void);
|
||||
|
||||
};
|
||||
|
||||
class Delete: public http::IRequest {
|
||||
public:
|
||||
Delete(void);
|
||||
Delete(std::string &data);
|
||||
~Delete(void);
|
||||
|
||||
void parse(const http::IRequest &request);
|
||||
|
||||
http::Response execute(void);
|
||||
|
||||
};
|
||||
|
||||
} // -namespace http
|
||||
} // -namespace webserv
|
||||
|
||||
#endif // __WEBSERV_REQUESTS_HTTP_REQUEST_HPP__
|
||||
|
Reference in New Issue
Block a user