-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.hpp
65 lines (57 loc) · 1.3 KB
/
server.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
#ifndef SERVER_HPP
#define SERVER_HPP
#include <list>
#include <netdb.h>
#include <string>
#include <sys/poll.h>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <sys/types.h>
#include <sys/socket.h>
#include <poll.h>
#define GET 0
#define POST 1
#define DELETE 2
#define BUFFER_SIZE 1024
class Location {
private:
public:
std::string path;
std::string root;
std::string index;
bool autoIndex;
bool trackAutoIndex;
int methods[3]; // GET 0 POST 1 DELETE 2 done
std::pair<std::string, std::string> redir; // return done
std::map<std::string, std::string> errorPage; // done
std::string upload; // not yet
std::map<std::string, std::string> cgiPath; // done
Location();
~Location();
};
class Server{
private:
public:
//conf part
std::vector<std::pair<std::string, std::string> > _listen;
std::vector<std::string> _listens;
std::string root;
std::string index;
std::string serverName;
long long maxBodySize;
std::map<std::string, std::string> errorPage;
Location servLoc;
std::vector<Location> loc;
//creation part
struct addrinfo *servInfo;
std::vector<pollfd> fds;
struct addrinfo hints;
std::vector<int> fd;
Server();
~Server();
int createServer(std::vector<std::string> &created);
void closeFd();
};
#endif