2025-01-20 16:52:02 +01:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
2025-02-03 18:39:23 +01:00
|
|
|
/* HttpRequest.hpp :+: :+: :+: */
|
2025-01-20 16:52:02 +01:00
|
|
|
/* +:+ +:+ +:+ */
|
2025-02-03 18:39:23 +01:00
|
|
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
2025-01-20 16:52:02 +01:00
|
|
|
/* +#+#+#+#+#+ +#+ */
|
2025-02-03 18:39:23 +01:00
|
|
|
/* Created: 2025/02/03 17:23:00 by mmoussou #+# #+# */
|
2025-02-12 01:36:19 +01:00
|
|
|
/* Updated: 2025/02/12 01:21:31 by mmoussou ### ########.fr */
|
2025-01-20 16:52:02 +01:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
2025-02-03 18:39:23 +01:00
|
|
|
#pragma once
|
2025-02-11 13:52:45 +01:00
|
|
|
#ifndef __WEBSERV_REQUESTS_HTTP_REQUEST_HPP__
|
|
|
|
# define __WEBSERV_REQUESTS_HTTP_REQUEST_HPP__
|
|
|
|
|
2025-02-11 22:26:50 +01:00
|
|
|
#include <fstream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <requests/HttpIMessage.hpp>
|
|
|
|
#include <requests/HttpResponse.hpp>
|
2025-02-11 13:52:45 +01:00
|
|
|
|
|
|
|
namespace webserv {
|
|
|
|
namespace http {
|
|
|
|
|
|
|
|
class IRequest: public http::IMessage {
|
|
|
|
public:
|
2025-02-12 01:36:19 +01:00
|
|
|
virtual void parse(http::IRequest const &request) = 0;
|
2025-02-11 13:52:45 +01:00
|
|
|
virtual http::Response execute(void) = 0;
|
|
|
|
|
2025-02-12 01:36:19 +01:00
|
|
|
//std::string str(void) const;
|
2025-02-11 13:52:45 +01:00
|
|
|
|
2025-02-12 01:36:19 +01:00
|
|
|
std::string getMethod(void) const;
|
|
|
|
std::string getTarget(void) const;
|
|
|
|
std::string getProtocol(void) const;
|
2025-02-11 13:52:45 +01:00
|
|
|
|
2025-02-12 01:36:19 +01:00
|
|
|
void setMethod(std::string const method);
|
|
|
|
void setTarget(std::string const target);
|
2025-02-11 13:52:45 +01:00
|
|
|
void setProtocol(std::string const protocol);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string _method;
|
|
|
|
std::string _target;
|
|
|
|
std::string _protocol;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class Get: public http::IRequest {
|
|
|
|
public:
|
|
|
|
Get(void);
|
|
|
|
Get(std::string &data);
|
|
|
|
|
|
|
|
void parse(const http::IRequest &request);
|
|
|
|
|
|
|
|
http::Response execute(void);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class Post: public http::IRequest {
|
|
|
|
public:
|
|
|
|
Post(void);
|
|
|
|
Post(std::string &data);
|
|
|
|
|
|
|
|
void parse(const http::IRequest &request);
|
|
|
|
|
|
|
|
http::Response execute(void);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class Delete: public http::IRequest {
|
|
|
|
public:
|
|
|
|
Delete(void);
|
|
|
|
Delete(std::string &data);
|
|
|
|
|
|
|
|
void parse(const http::IRequest &request);
|
|
|
|
|
|
|
|
http::Response execute(void);
|
|
|
|
|
2025-02-03 18:39:23 +01:00
|
|
|
};
|
|
|
|
|
2025-02-11 13:52:45 +01:00
|
|
|
} // -namespace http
|
|
|
|
} // -namespace webserv
|
2025-02-03 18:39:23 +01:00
|
|
|
|
2025-02-11 13:52:45 +01:00
|
|
|
#endif // __WEBSERV_REQUESTS_HTTP_REQUEST_HPP__
|