-
Notifications
You must be signed in to change notification settings - Fork 0
/
Box.hpp
69 lines (64 loc) · 2.72 KB
/
Box.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Box.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hlakhal- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/17 13:22:54 by hlakhal- #+# #+# */
/* Updated: 2024/02/26 09:50:56 by hlakhal- ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef BOX_HPP
#define BOX_HPP
#include"webServer.hpp"
#include"methods/methods.hpp"
#include <iostream>
#include <arpa/inet.h>
#include <errno.h>
#include <cstring>
#include <sys/socket.h>
#include <unistd.h>
#include <sys/epoll.h>
#include <algorithm>
#include"errorMessage.hpp"
#include<stack>
# define GREEN "\033[92m"
# define RESET "\033[0m"
# define RED "\033[31m"
# define CYAN "\033[96m"
typedef std::map<int , std::string> mapR;
class Box
{
private:
webServer _InfoServer;
std::map<int,Client> clients;
std::string QueryString;
__uint16_t _listen;
u_long _host;
void parssingRequest(std::string& buffer);
void readRequest(int fdRequest, int epollFd);
public:
Box();
Box(const Box& other);
void setInfo(const webServer& InfoServer);
void setUpServer(webServer& data);
void sendRequest(int fd);
int matchLocation(std::vector<Location>& loc, std::string path, int fd);
void methodAllowd(std::vector<std::string>& methods, const std::string& method, int id);
Box& operator=(const Box& other);
bool checkDup(const std::vector<Server>& sr, std::vector<int>& posServer);
bool checkName(const std::vector<Server>& sr, std::string name, size_t &i,std::vector<int>& posServer);
void makeSocketNonBlocking(int sockfd);
std::map<int,Client> &getClients() ;
std::string removeSlach(std::string& str);
const std::string& getQueryString() const;
// std::string FullQueryString(std::string& path);
webServer& getWebServer() ;
void sendResponse(int fd);
void timeOut(int fd, clock_t endTime);
static bool ComparePath(const Location& loc1, const Location& loc2);
std::string generetPage(int status, std::map<int, std::string> httpMessage);
~Box();
};
#endif